Job
A job represent a task that starts, does something and finishes. Kubernetes allows to create jobs where containers do something and stop post completion.
apiVersion: batch/v1
kind: Job
metadata:
name: math-add-parallel
namespace: learning
spec:
completions: 5
template:
spec:
restartPolicy: Never
containers:
- name: add
image: ubuntu
command: ["expr"]
args: ["2", "+", "2"]
completions
defines the number of times to run the pod in the job.
We can run pods in parallel using spec.parallelism
with value set to pods we want to run in parallel.
apiVersion: batch/v1
kind: Job
metadata:
name: math-add-parallel
namespace: learning
spec:
completions: 5
parallelism: 3
template:
spec:
restartPolicy: Never
containers:
- name: add
image: ubuntu
command: ["expr"]
args: ["2", "+", "2"]