In my case I have not added any parameter for backofflimit in kind:job so job will retry for 6 times and if it is completed it will remove all pods Error and Completed as used hook delete policy.
apiVersion: batch/v1
kind: Job
metadata:
name: create-job
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation"
"helm.sh/hook-weight": "1"
spec:
template:
spec:
restartPolicy: Never
containers:
- name: create-job
Problem Statement: This job is dependent on another Pod, So now that pod is taking time to come in running state. So job runs for 6 times and not able to succeed, I have added backofflimit: 10, now the job reties 10 times and if it success in between then does not removed Error and Completed pods by default.
Thanks
Your failed pod should be automatically deleted once hitting backofflimit (default to 6) if your restartPolicy is defined as onFailure.
In my case - cronjob defined and should run every 15mins:
Describe the job - which tells it hit backoffLimit
Check it out https://github.com/kubernetes/kubernetes/issues/74848