Start with a Job from the command line:
sh
kubectl create job seed --image=busybox -n plains-1tum1hg -- sh -c 'echo seeding; sleep 2'When it is Complete, read its logs. Then apply a Job that needs four successes and runs two Pods at a time:
sh
kubectl apply -n plains-1tum1hg -f - <<EOF
apiVersion: batch/v1
kind: Job
metadata:
name: hashes
spec:
completions: 4
parallelism: 2
template:
spec:
restartPolicy: Never
containers:
- name: main
image: busybox
command: ["sh", "-c", "echo hashing; sleep 2"]
EOFFinally a Job whose command exits 1 every time, with two retries allowed:
sh
kubectl apply -n plains-1tum1hg -f - <<EOF
apiVersion: batch/v1
kind: Job
metadata:
name: flaky
spec:
backoffLimit: 2
template:
spec:
restartPolicy: Never
containers:
- name: main
image: busybox
command: ["sh", "-c", "echo attempt; exit 1"]
EOFPods appear one at a time, each ending in Error, with growing waits. After the third, describe job flaky ends with a Warning event. Its Reason is an answer.