KodeCloud CKAD Jobs
Links: 111 KodeCloud Index
Short temporary work load in docker:
- Docker container finishes the job and then exits.
- When we run the
docker pscommand we can see the container in an exited state with the status code of the operation.
Short temporary work load in k8s:
- A pod is created and it does the job.
- The pod goes into the completed state.
- But k8s then recreates the container in an attempt to leave it running.
- This happens a fixed number of times.
This happens since k8s wants our applications to live forever. The default behaviour of the pods is to restart the container in an attempt to leave it RUNNING.
This behaviour is defined by the
restartPolicyset on the pod whose default value is always.
- This is why the pod always recreates the container when the container exits.
- We can override this property by setting it to never or on failure.
Now suppose you have a batch processing job in which you want a lot of pods.
- We need a job manager.
- A ReplicaSet is needed to ensure a specified number of pods is running at each time a Job is used to perform a given task to completion.
Working with jobs:
- We see that the pod exits after successfully completing the job and is not restarted.
- Using multiple pods in a job:
- Completions here refer to the number of successful completions that is required from the job.
- By default pods are created one after another. So if one fails a new pod is created and jobs are attempted until we have the desired number of completions
- We can do the jobs in parallel using the
- A cron job is job that can be scheduled and run periodically.
Last updated: 2022-09-26