Problem statement
Namespace media-pipeline encodes the master library, and every kind of storage in it is wrong at once. The encoder keeps its pass counter and mid-job state on its container filesystem and aborts its first pass on purpose, so every restart begins the job from zero and it never finishes. The publisher next to it looks for that job state in its own filesystem and never finds it. Neither of them can see the master library at all, even though library-seeder sealed it onto a claim and exited. retired-render holds renders nobody has asked for since 2021 and is still costing space, and offsite-mirror has been Pending since the day it was created and always will be.
Give the pipeline the three kinds of storage it actually needs, clear out what it does not, and produce the report that says which of them survives what.
About this exercise
This brings together the topic's three exercises:
- Ephemeral volumes - a pod-lifetime directory shared between containers, and a memory-backed one beside it (Ephemeral Volumes)
- Claims - a request for storage the cluster provisions, binds and hands to whichever pod asks for it (PVCs & Dynamic Provisioning)
- Reclaim - what becomes of the volume when the claim is deleted, and the claims that will never bind (Claim Lifecycle & Reclaim)
One question runs through all three: what is this data's lifetime? A container's filesystem lasts until the container restarts. An emptyDir lasts exactly as long as the pod - a restart keeps it, a replacement destroys it. A claim's volume outlives every pod that ever mounted it, and lasts until the claim is deleted, at which point its class's reclaim policy decides whether the bytes are destroyed or left behind, Released, for somebody to deal with by hand. The cluster's default class deletes; media-retain - the same provisioner, the same binding behaviour - retains.
Getting that wrong in either direction is expensive: mid-job state on a container filesystem is redone from scratch on every restart, and a cache on a claim is durable storage paid for by the gigabyte to hold data nobody would miss. And because both classes here bind on first consumer, a claim nothing uses sits Pending forever without anything being wrong - which looks exactly like a claim naming a class that does not exist, until you read the event.
kubectl explain pod.spec.volumes, kubectl explain pvc.spec and kubectl explain sc list the fields.
How this project is graded
The grader reads every volume, mount and claim back off the live pipeline and compares them against the specification below, then watches it work: the pass counter has to climb across a real container restart, each container has to see what the other one wrote, and the master dataset read from inside the encoder has to hash to exactly what the seeder wrote. To find out whether the scratch space outlives the pod, it copies your pod spec into a namespace of its own, runs it until the job state has carried a restart, deletes that copy and recreates it. Then it runs your report twice: once against media-pipeline, where every line must match what the cluster reports at that moment, and once against a second namespace it builds from your pod with the memory-backed volume dropped, the library claim repointed at the retaining class, and two claims that will never bind. Both grader-owned namespaces are removed afterwards, and nothing in media-pipeline is created, patched or deleted by the grader.
What you will build
media-encoder keeps its two containers, their images and their commands exactly as they are - manifest.yaml holds the pod as it runs today - and gains exactly these three volumes and no others:
scratch pod-lifetime throwaway space, node-backed
mounted at /scratch in the encoder container
mounted at /feed in the publisher container
cache pod-lifetime throwaway space, memory-backed, limited to 32Mi
mounted at /cache in the encoder container only
library the claim media-library
mounted at /library in the encoder container only
The encoder writes passes, job-state.txt, its thumbnails and its generation line on its own, and the publisher copies what it finds; you only decide where those directories come from. The master library is already on media-library, sealed there by library-seeder, which finished and exited.
Then the clear-out, and the report:
retired-render expired: the claim goes, and the volume behind it goes with itsurvival.sh [namespace] defaults to media-pipeline
survival.sh prints one line per emptyDir or claim volume of media-encoder - the token volume every pod is given is not storage and is not reported - sorted by volume name, and then one line per Pending claim in the namespace, sorted by claim name:
MATRIX <volume> <source> <mounts> <restart> <replacement> <claim> PENDING <claim> <reason>source emptyDir, emptyDir:<medium> when the volume names one, or claim:<claim name> mounts <container>:<path> for every container that mounts the volume, comma-separated, sorted by container name restart keep or lose: does the data survive a restart of the container replacement keep or lose: does it survive the pod being replaced claim keep or lose: does it survive the deletion of the claim behind it, which its storage class decides - or a single - for a volume that has no claim to lose reason the reason on the event the cluster recorded about that claim
The tests
- Scratch_state_survives_the_container_restart - the aborted pass stops costing anything and the encode finishes
- Scratch_directory_is_shared_by_both_workers - one directory under two names, and the cache and library not in it
- Scratch_space_does_not_outlive_its_pod - a replaced pod starts from an empty directory
- Store_claim_binds_with_the_requested_size_and_mode - the claim, the volume it got and the mount all agree
- Store_dataset_is_byte_exact_across_the_pod_handoff - the seeder's bytes, hashed from inside a pod that never wrote them
- Reclaim_deleting_the_claim_disposes_its_volume - the expired claim gone, and its volume with it
- Reclaim_unsatisfiable_claim_stays_pending_with_its_event - the claim that will never bind, and the cluster's reason for it
- Composition_volumes_and_mounts_match_the_pipeline_spec - three volumes, three lifetimes, mounted where they belong
- Composition_survival_matrix_matches_the_live_pipeline - the report matches the cluster line for line
- Composition_matrix_run_against_a_namespace_the_grader_built - the same report, on a namespace it has never seen
When every test passes
You have:
- Mid-job state a container restart no longer destroys, and two containers handing work to each other through it
- A cache that is fast, capped, and honestly labelled as throwaway
- A master library on storage the cluster provisioned, byte-exact under a pod that did not write it
- Expired storage actually reclaimed, instead of a deleted claim and a volume nobody bills for
- One command that says, for any namespace running this pipeline, exactly what survives a restart, a replacement and a deletion
- The next topic unlocked
Verify
Click Test.
