Kubernetes 101 : Running a pod to its completion - Jobs -
Running pods until it finishes and exits:
The below pod - Job - runs until it completes its tasks, and then exits either with a success or a failure "exit" code.
We could see that by checking the "exit" code of a pod, using the below command:
If a pod fails, it is restarted until the limit of "restarts" is reached.
We could set this limit using the following parameter in the Job's YAML file: "backoffLimit".
We can't use the default "restartPolicy: Always" with Jobs.
The restartPolicy defines the action Kubernetes takes when a container's process finishes its task.
Below we have an example of a YAML file for a Job: