Problem statement
A one-shot task pod is restarted forever by the cluster, while a crashing server pod's exits go unrecorded - both policies are backwards. manifest.yaml holds both pods exactly as described.
About this exercise
A pod tells the cluster what to do when its container ends, through the pod-level restart policy. The three values differ in when the container is brought back: always, only on failure, or never. That choice decides two things learners usually discover the hard way:
- A task that completes can only reach the terminal phase Succeeded under a policy that permits stopping. Under the wrong one the cluster restarts a job that already did its work, and the pod never settles.
- A server that crashes is only restarted under a policy that asks for it - and Kubernetes deliberately waits longer between each attempt (a backoff), so a broken image cannot spin the node.
Every restart leaves a record. The container status carries a restart count, the current state, and a last state describing the previous instance - its exit code, its reason, when it finished. That last-state record is the only place a crash's exit code survives; without a restart it does not exist at all.
kubectl get pod -o jsonpath=... reads any of these fields; kubectl describe pod shows them laid out; kubectl explain pod.spec.restartPolicy and kubectl explain pod.status.containerStatuses document the schema.
How this project is graded
The grader reads manifest.yaml and then watches the live pods until they reach the states their policies imply, so both pods must be applied and left running.
What you will build
Two pods in manifest.yaml, already written except for their policies:
nightly-report busybox, prints and exits 0 -> must end up Succeeded, never restarted flaky-server busybox, prints and exits 7 -> must be restarted repeatedly, with backoff
Step 1 - the right policy for each lifecycle
Give each pod the restart policy its workload actually needs, and apply the file. Note the policy cannot be changed on a running pod - delete and re-apply.
policies_declared_per_workload should pass
Step 2 - the completing task
nightly-report must reach Succeeded with zero restarts and exit code 0 recorded.
completing_pod_succeeds_without_restarts should pass
Step 3 - the crashing server
flaky-server must accumulate restarts, and its status must record the previous instance's exit code and reason. Read both out of the pod and save them:
answers/exit-code.txt the exit code the previous instance terminated with answers/restarts.txt how many times the container has been restarted
crashing_pod_restarts_with_backoff, last_state_records_the_exit_reason_and_code and saved_exit_code_and_restart_count_match_status should pass
When every test passes
You have:
- Restart policies chosen from what the workload does, not copied from an example
- A completing task that stays completed
- A crashing server the cluster keeps reviving, at a rate that protects the node
- The status fields that prove all of it - restart counts and last-state exit codes, read straight out of the pod
You do not have yet:
- All of it in one bring-up. A server, a configured variant and a one-shot task, brought up together from bare manifests, is the next challenge.
Verify
Click Test after every step.
