Kubernetes CronJobs allow to specify following:
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
However this is not the case for Kubernetes Jobs – these fields are undefined and the pods are immediately deleted after completion.
Is there a way to keep the jobs' pods after completion for inspection?
CodePudding user response:
The only way to keep alive is let him doing something. When your job run and the work is finished it exits with code 0, when an error occours it exits with a different code.
If you need to access your container after the job is finished let him do someting like "sleep infinity".....
In your podTemplate of your job.yaml
command:
- sh
- -c
- |
myjobcommand
sleep 999999
Update
To log terminated pods use the -p switch
kubectl logs podname -p -n mynamespace
it should work till 1 hour (default settings) after the pod terminated