Problem statement
Namespace archive-store is the case archive, and its storage is a mess. The imported case set sits on a claim nobody reads, because case-api serves out of a throwaway directory of its own. cold-archive holds data the retention policy expired years ago and is still costing space. Two more claims are Pending for two completely different reasons, and the listing shows the same word for both. Sort the estate out, and prove where every volume went.
About this exercise
A claim and the volume behind it have separate lives. The claim is a request in a namespace; the volume is a piece of storage in the cluster. What happens to the volume when the claim goes away is decided in advance, by the reclaim policy of the class that provisioned it:
- Delete - the claim's deletion destroys the volume and the data on it. This is what the cluster's default class does, and it is why deleting a claim is not a bookkeeping operation.
- Retain - the volume stays. It keeps its data, it keeps a claimRef naming the claim that is now gone, and it reports the phase Released: owned by nobody, and deliberately not handed to the next claim in line. Somebody has to deal with it by hand, and that is the point - the bytes survive an accident.
The cluster has both: the default class deletes, and archive-retain - the same provisioner, the same binding behaviour - retains.
Two more facts about the life cycle matter here:
- A claim that a pod still references cannot be deleted. The API accepts the request and the claim sits in Terminating until the last pod using it is gone. Storage in use is protected from a careless delete.
- Binding mode decides when a volume is created for a claim. Both classes here bind on first consumer, so a claim with no pod using it stays Pending - indefinitely, and correctly. A claim naming a class the cluster does not have is also Pending, and will be forever. The phase does not tell the two apart; the events the cluster records about the claim do, and they carry a different reason each.
kubectl explain sc lists the fields of a storage class, kubectl explain pv.spec those of a volume, and kubectl explain pvc.status those of a claim's status.
How this project is graded
The grader reads the claims, the volumes and the pod back off the live cluster: the bindings and modes against the specification below, the case set read from inside the running container, and each retired volume looked up by the claim it used to belong to. The volume that cold-archive was bound to was recorded when the namespace was seeded, so the grader knows exactly which volume had to disappear. Nothing in archive-store is created, patched or deleted by the grader; a claim you decommission is not seeded back on top of your work.
What you will build
case-api keeps its container, image and command exactly as they are - manifest.yaml holds the pod as it runs today - and gets its data directory from storage that already holds the case set:
Pod case-api takes its /var/lib/archive directory from the claim case-files instead of from a throwaway directory of its own
The imported case set is already on case-files, sealed there by case-importer, which finished and exited. The container appends one line to case.log on every start, and increments the boots counter next to it.
Then three retirements and one report:
cold-archive expired: the claim goes, and the volume behind it goes with itaudit-archive a claim you create in archive-store storage class archive-retain access mode ReadWriteOnce size 256Mi it has to reach Bound - which takes a consumer - and then be deleted, leaving its volume behind
answers/pending-claims.txt one line per claim of archive-store that is Pending, sorted by claim name: <claim> <reason on the event the cluster recorded>
Step 1 - put the API on the data
Point case-api at case-files. When it comes up it has to find the line case-importer left there, and append its own generation next to it.
case_api_takes_its_directory_from_the_bound_claim and the_imported_dataset_survives_the_pod_handoff should pass
Step 2 - retire the expired archive
cold-archive and the volume behind it must both be gone. The claim's class deletes on release, so one of those follows from the other - but something in the namespace is still holding the claim, and while it does the deletion will not complete.
deleting_the_claim_disposes_its_volume_under_the_delete_policy should pass
Step 3 - keep the bytes, drop the claim
Create audit-archive as specified, get it bound to a volume, then delete the claim. Its class retains: the volume has to still be there afterwards, reporting Released and still naming the claim that asked for it.
the_retained_volume_outlives_the_claim_that_asked_for_it should pass
Step 4 - two kinds of Pending
Both remaining claims read Pending in a listing and only one of them will ever bind. Write down each one with the reason the cluster recorded about it, exactly as the cluster spells it.
the_unsatisfiable_claim_is_pending_with_its_provisioning_event and the_unconsumed_claim_is_pending_by_the_class_binding_mode should pass
When every test passes
You have:
- A pod serving the dataset an earlier pod wrote, on storage neither of them owns
- Expired storage actually reclaimed, instead of a deleted claim and a volume nobody bills for
- A volume that outlived its claim on purpose, still naming what it belonged to
- The difference between a claim that is waiting and a claim that is never going to bind, taken from the cluster's own record
You do not have yet:
- All of it working at once. Scratch space, a durable dataset and the reclaim rules in one pipeline is the next exercise.
Verify
Click Test after every step.
