Reputation: 114
I have problems to delete automatically the completed jobs which were started by a CronJob.
As I read in this QA here and here, and in the official documentation, this can be done establishing the job history limit
.spec.successfulJobsHistoryLimit
and .spec.failedJobsHistoryLimit
. I have done it, and it is established to 1 for both cases. But my cluster is saving more than 1 completed job, in fact, it is saving more than the default which is 3 successful jobs and 1 for failed jobs.
My current CronJob configuration is
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: some-name-cron
spec:
schedule: "00 05 1/1 * ?"
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
spec: ...
And my versions are:
- Client version: Client Version: version.Info{Major:"1", Minor:"9",
- Server version: Server Version: version.Info{Major:"1", Minor:"8+",
So, what I am doing wrong?
I've attached a image with the k8s dashboard.
Upvotes: 6
Views: 27738
Reputation: 518
You can use jobs history limits successfulJobsHistoryLimit and failedJobsHistoryLimit to set how many completed and failed jobs should be kept.
You can check for more details on it in the Kubernetes docs here:
Kubernetes - Cronjob: Jobs History Limits
Upvotes: 6