How to retain Kubernetes failed Pods associated with a Job
I have tried with annotations available at the Job level.
restartPolicy
backOffLimit
TTLAfterFinished
activeDeadlineSeconds
apiVersion: batch/v1
kind: Job
metadata:
name: sample-job
labels:
app: "sample-job"
chart: "sample-chart"
spec:
template:
metadata:
labels:
app: "sample-job"
spec:
backOffLimit: 5
restartPolicy: OnFailure
containers:
- name: sample-job-container
image: <image>
imagePullPolicy: IfNotPresent
I want to know the configuration which I can apply on the Job file to retain pods forever even when Job fails after specified retries for debugging purpose
When a Job completes (regardless of whether it has succeeded or failed), the Job object and all Pod objects it manages remains. However, when you delete a Job object, all of the Pods it is managing also gets deleted. So to retain the Pods, just don't delete the Job.