Kubernetes Job Cleanup

It looks like starting with Kubernetes 1.6 (and the v2alpha1 api version), if you’re using cronjobs to create the jobs (that, in turn, create your pods), you’ll be able to limit how many old jobs are kept. Just add the following to your job spec:

successfulJobsHistoryLimit: X
failedJobsHistoryLimit: Y

Where X and Y are the limits of how many previously run jobs the system should keep around (it keeps jobs around indefinitely by default [at least on version 1.5.])

Edit 2018-09-29:

For newer K8S versions, updated links with documentation for this are here:

  • CronJob – Job History Limits

  • CronJob API Spec

Leave a Comment

tech