Skip to content

Delete complete/failed Kubernetes jobs after one hour

License

Notifications You must be signed in to change notification settings

vainuio/kube-job-cleaner

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Deploying:

$ kubectl apply -f deploy/

There are a few options:

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

About

Delete complete/failed Kubernetes jobs after one hour

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 81.3%
  • Makefile 14.0%
  • Dockerfile 4.7%