Delete complete/failed Kubernetes jobs after one hour
Clone or download
Latest commit 0cbfe82 Jan 10, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
deploy Fix deployment (#17) Dec 1, 2018
.gitignore initial commit Jan 30, 2017
Dockerfile Alpine 3.8 Jan 10, 2019
LICENSE add README and LICENSE Jan 31, 2017
Makefile Alpine 3.8 Jan 10, 2019
README.rst describe options in README Jun 10, 2017 Handle pods with failed initcontainers or weird statuses (#18) Jan 10, 2019
tox.ini fix flake8 Feb 16, 2018


Kubernetes Job Cleaner

Very simple script to delete all completed jobs after X seconds (default: one hour).

Kubernetes jobs are not cleaned up by default and completed pods are never deleted. Running jobs frequently (like every few minutes) quickly thrashes the Kubernetes API server with unnecessary pod resources. A significant slowdown of the API server can be observed with increasing number of completed jobs/pods hanging around. To mitigate this, This small kube-job-cleaner script runs as a CronJob every hour and cleans up completed jobs/pods.

See Zalando's Running Kubernetes in Production document for more information.

Building the Docker image:

$ make


$ kubectl apply -f deploy/

There are a few options:

Number of seconds after job completion to remove the job (default: 1 hour)
Kill all jobs after X seconds (default: never)
Do not actually remove any jobs, only print what would be done