This scenario shows how K8s job object works on minikube
- Copy and save (below) as file on your PC (job.yaml).
- File: https://github.com/omerbsezer/Fast-Kubernetes/blob/main/labs/job/job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
parallelism: 2 # each step how many pods start in parallel at a time
completions: 10 # number of pods that run and complete job at the end of the time
backoffLimit: 5 # to tolerate fail number of job, after 5 times of failure, not try to continue job, fail the job
activeDeadlineSeconds: 100 # if this job is not completed in 100 seconds, fail the job
template:
spec:
containers:
- name: pi
image: perl # image is perl from docker
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] # it calculates the first 2000 digits of pi number
restartPolicy: Never
- Create job:
- Watch pods' status:
- Watch job's status:
- After pods' completion, we can see the logs of each pods. Pods are not deleted after the completion of task on each pod.
- Delete job: