Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theMagicalKarp/kube-janitor
Kubernetes Job Cleaner
https://github.com/theMagicalKarp/kube-janitor
helm kubernetes
Last synced: 12 days ago
JSON representation
Kubernetes Job Cleaner
- Host: GitHub
- URL: https://github.com/theMagicalKarp/kube-janitor
- Owner: theMagicalKarp
- License: mit
- Created: 2018-08-28T22:53:58.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-17T18:35:20.000Z (over 4 years ago)
- Last Synced: 2024-06-21T09:09:05.748Z (5 months ago)
- Topics: helm, kubernetes
- Language: Go
- Homepage:
- Size: 102 KB
- Stars: 44
- Watchers: 3
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kube-janitor
[![Build Status](https://travis-ci.com/theMagicalKarp/kube-janitor.svg?branch=master)](https://travis-ci.com/theMagicalKarp/kube-janitor)
[![Go Report Card](https://goreportcard.com/badge/github.com/theMagicalKarp/kube-janitor)](https://goreportcard.com/report/github.com/theMagicalKarp/kube-janitor)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](thejanitor.png)
## 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
* [Kubernetes](https://kubernetes.io/)
* [Helm](https://helm.sh/)## 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
* [Minikube](https://github.com/kubernetes/minikube)
* [Helm](https://helm.sh/)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
* Cleanup orphaned Pods from dirty deletions
* Provide instructions for running outside cluster
* Automate publishing releases to https://themagicalkarp.github.io/charts
* Tidy up documentation