I have a CronJob which runs every 15 Mins. Say, Its running for the last 1 year. Is it possible to get the complete history using Kube API? Or, Is it possible to control the maximum history that can be stored? Also, Can we get the status( Success/ Failure ) of each run along with the total completion time? Does the POD die after completing the Job?
A CronJob creates a Job object for each execution.
For regular Jobs you can configure .spec.ttlSecondsAfterFinished
along with the TTLAfterFinished
feature gate to configure which Job instances are retained.
For CronJob you can specify the .spec.successfulJobsHistoryLimit
to configure the number of managed Job instances to be retained.
You can get the desired information from these objects.
The pod does not die when the job completes, it is the other way around: If the pod terminates without an error, the job is considered completed.
The .spec.successfulJobsHistoryLimit and .spec.failedJobsHistoryLimit fields are optional. These fields specify how many completed and failed jobs should be kept. By default, they are set to 3 and 1 respectively.