Namespace plains-1t9hm7z is empty.
A Job that succeeds
kubectl create job seed-1t9hm7z --image=busybox -n plains-1t9hm7z -- sh -c 'echo seeding; sleep 2'
kubectl get jobs -n plains-1t9hm7zRun get jobs again after a few seconds: STATUS goes from Running to Complete, COMPLETIONS to 1/1.
kubectl logs job/seed-1t9hm7z -n plains-1t9hm7zOne word comes back. That is an answer.
A Job that fails
Apply this. The command exits 1 every time and backoffLimit is 2.
kubectl apply -n plains-1t9hm7z -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"]
EOF
kubectl get pods -n plains-1t9hm7zPods appear one at a time, each ending in Error. Retries wait 10 s, then 20 s. After the third failure, about 35 seconds in:
kubectl get jobs -n plains-1t9hm7z
kubectl describe job flaky -n plains-1t9hm7zSTATUS is Failed. describe ends with a Warning event whose Reason is the answer to the next objective.
A CronJob
kubectl create cronjob cleanup --image=busybox --schedule="*/1 * * * *" -n plains-1t9hm7z -- sh -c 'echo cleaning'
kubectl get cronjobs -n plains-1t9hm7zLAST SCHEDULE is <none> until the next minute boundary. Do not wait for it. Run the template once by hand:
kubectl create job manual-1t9hm7z --from=cronjob/cleanup -n plains-1t9hm7z
kubectl get jobs -n plains-1t9hm7z
kubectl logs job/manual-1t9hm7z -n plains-1t9hm7zThe manual Job carries an annotation cronjob.kubernetes.io/instantiate: manual. kubectl describe job manual-1t9hm7z shows it.