GithubHelp home page GithubHelp logo

kube-janitor's Introduction

kube-janitor

Build Status Go Report Card

Kube-janitor is a automation tool to clean up finished jobs in Kubernetes. It is designed to be highly configurable and deployable via helm.

the-kube-janitor

Why

As of v1.11 Kubernetes does not clean up failed or successful jobs automatically.

When a Job completes, no more Pods are created, but the Pods are not deleted either. Keeping them around allows you to still view the logs of completed pods to check for errors, warnings, or other diagnostic output. The job object also remains after it is completed so that you can view its status. It is up to the user to delete old jobs after noting their status.

Although Kubernetes does provide an activeDeadlineSeconds on job configurations.

The activeDeadlineSeconds applies to the duration of the job, no matter how many Pods are created. Once a Job reaches activeDeadlineSeconds, the Job and all of its Pods are terminated. The result is that the job has a status with reason: DeadlineExceeded.

However this option has the potential to kill your job even before it's finished. Kube-janitor aims to cleanup only after your job has finished regardless of failure or success.

Requirements

Getting Started

To immediately install kube-janitor run the following commands.

helm repo add themagicalkarp https://themagicalkarp.github.io/charts
helm upgrade --install kube-janitor --namespace kube-system themagicalkarp/kube-janitor

This'll register https://themagicalkarp.github.io/charts as repo in your helm client and deploy kube-janitor to your cluster.

If you don't want to install helm in your cluster you can render the configuration and pipe it to kubectl.

helm template kube-janitor --name kube-janitor | kubectl create -f -

Options

CMD Params

These are flags you can specify when invoking the kube-janitor binary directly located in the docker image.

  • -annotation="kube.janitor.io" The prefix to use when looking for kube-janitor annotations
  • -namespace="" The namespace to target for cleanup. By default checks all namespaces
  • -expiration=60 The amount of minutes before a job is considered expired and therefore targeted for deletion.
  • -verbose If present logs detailed information on jobs found and deleted
  • -dryrun If present prevents any job deletions from occuring

Job Annotations

These are annotations you can specify per job to configure kube-janitor behavior.

  • kube.janitor.io/expiration A float, that if specified, overrides the expiration limit for the job
  • kube.janitor.io/ignore A boolean, that if true, kube-janitor ignores

Build/Test

Docker is the source of truth for building and testing the code. This Dockerfile runs the tests and ensures correct formatting. If either of those steps fail we prevent the image from being built.

docker build -t kube-janitor:latest .

Local Development with Minikube

Requirements

To build and deploy locally into your Minikube cluster run the following commands.

eval $(minikube docker-env)
docker build -t themagicalkarp/kube-janitor:local .
helm init
helm install kube-janitor --set image.tag="local" --set image.pullPolicy="Never"

What's Next

kube-janitor's People

Contributors

abatilo avatar kevinfrommelt avatar philoserf avatar simkev2 avatar sunghoonkim-wk avatar themagicalkarp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kube-janitor's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.