Problem statement
Nothing in namespace capacity-planning declares what it needs, so the node hosts a lottery: some days everything fits, some days a pod sits Pending for an hour, and nobody can say why either happened. checkout-api and report-worker are running there right now with no resource declaration at all, and legacy-import has been Pending since the day someone applied it.
About this exercise
A request is what a container tells the scheduler it needs. It is not a cap and it is not what the container gets - it is the number the scheduler does arithmetic with. For every node the scheduler keeps one sum per resource: the requests of every pod already placed there. A pod fits on a node when, for each resource, that sum plus the pod's own request still fits inside the node's allocatable amount.
Allocatable is not the machine's size. The node reports capacity - what the hardware has - and allocatable - what is left for pods after the kubelet reserves room for the system and for itself. Only allocatable is spent on requests.
Three consequences follow, and this exercise walks into all three:
- A pod with no request counts as zero. The scheduler will place any number of them on a node, because on paper they cost nothing. That is the lottery: placement decided by luck, and the node's ledger reporting plenty of room while the machine is full.
- Requests are reserved, not measured. A container that requests 128Mi and uses 4Mi still holds 128Mi against the node's sum. Requests too high waste the node; too low and the arithmetic is a fiction.
- A request larger than allocatable can never be satisfied. No amount of waiting helps: no node in the cluster has that much to give, so the pod stays Pending and the scheduler records why on the pod as an event.
CPU is measured in cores, and in millicores - thousandths of a core, written with an m suffix. Memory is measured in bytes, with the binary suffixes Ki, Mi and Gi.
kubectl explain pod.spec.containers.resources and kubectl explain node.status are the reference for the fields; a node description renders both the allocatable amounts and the per-pod request accounting.
How this project is graded
The grader reads the live cluster: what each pod declares, where the scheduler put it, what the node's own accounting says about it, and what the cluster recorded about the pod that does not fit. Saved answers are compared against the node as it reports itself right now. The namespace is re-seeded before every run, so a pod you never built cannot pass by accident - but a pod the exercise asks you to remove stays removed.
What you will build
Everything lives in namespace capacity-planning. All three pods run busybox:1.36 and stay alive.
1. Replace checkout-api and report-worker so each declares what it needs. A pod's resources are immutable, so these are replacements, not edits:
pod checkout-api container api requests cpu 100m memory 64Mi pod report-worker container worker requests cpu 250m memory 128Mi
Both must end up Running and placed on the node.
2. Pod analytics-batch, container batch, that asks for more memory than exists:
requests memory strictly greater than the memory the node reports as allocatable
It will never be scheduled. That is the point - leave it Pending, with the scheduler's own explanation attached to it.
3. Two answers in answers/:
allocatable.txt the node's allocatable cpu and memory, one per line, exactly as
the node reports them:
cpu <value>
memory <value>
allocated.txt a full description of the node, including its Allocated resources
section and the per-pod request rows
4. legacy-import must no longer exist in capacity-planning.
Step 1 - say what you need
Give checkout-api and report-worker the requests above and get both running. Once they carry requests, the node's accounting stops pretending they are free: each one's cpu and memory request shows up against the node in its own right.
cpu_and_memory_requests_declared_per_spec, requested_workloads_schedule_and_run and node_accounting_shows_the_declared_requests should pass
Step 2 - ask for more than exists
Build analytics-batch with a memory request above the node's allocatable memory. It stays Pending forever, and the scheduler says exactly why on the pod itself.
oversized_request_stays_pending and insufficient_resource_event_recorded should pass
Step 3 - read the node's ledger
Save what the node reports as allocatable, and the accounting page that shows how much of it is already spoken for.
node_allocatable_saved_exactly and node_allocated_requests_saved should pass
Step 4 - retire what will never fit
legacy-import was applied with a request no node in this cluster can satisfy, and it has been occupying the Pending column ever since. Remove it.
unschedulable_leftover_removed should pass
When every test passes
You have:
- Workloads that tell the scheduler what they need instead of costing zero on paper
- Placement that follows arithmetic you can check, not luck
- A pod that proves what happens when the arithmetic cannot work out, with the cluster's own reason attached
- The node's allocatable amount and the share of it already committed, read from the node itself
You do not have yet:
- Any ceiling on what a container may actually use. A request is a reservation, not a cap; caps are the next exercise.
Verify
Click Test after every step.
