All lessons · Guided routes

Simulator · Containers and Kubernetes

Kubernetes scheduling and limits

Quillfern runs its orders API as a Deployment on a three-node cluster. Change the replicas, the requests and limits, and how much memory the container really uses.

At Quillfern Parcels. This is the system from chapter 4 of the Quillfern story, "From one server to a cluster": Bookings triple. One server cannot hold the load, and a failed server still means an outage.

What the model simplifies

The scheduler places each replica on a node whose free allocatable CPU and memory cover its requests, preferring the node with the most room left (the default least-allocated scoring, with no other plugins). Limits do not affect placement: CPU over the limit is throttled, memory over the limit gets the container killed (OOMKilled, exit code 137) and restarted with a growing back-off. Every number on this page comes from one shared set of calculations, which the simulation questions use too, so a question can never disagree with what the simulator shows.

The drills, written out

New pods stay Pending after a scale-up
  1. Healthy state. Three replicas, each requesting 500m CPU and 512Mi, are spread over the three nodes and all ready.
  2. Trigger. Before a sale, someone scales to six replicas and raises the CPU request to 1500m "to be safe".
  3. What is affected. The new pods, and the sale traffic they were meant to serve.
  4. Symptoms. kubectl get pods shows 5 pods Pending for minutes. The old pods were replaced in a rolling update, so capacity went down, not up.
  5. Metrics. 1 of 6 scheduled. Free CPU is about 1100m on node-a, 1400m on node-b, and 2600m on node-c, so only node-c fits a 1500m pod, and only once.
    node-a free: 1100m CPU, 2596Mi
    node-b free: 1400m CPU, 2992Mi
    node-c free: 2600m CPU, 5592Mi
  6. Logs. The pod events name the reason.
    Warning  FailedScheduling  0/3 nodes are available: node-a: insufficient cpu (1100m free, 1500m requested); node-b: insufficient cpu (1400m free, 1500m requested); node-c: insufficient cpu (1100m free, 1500m requested).
  7. Reasoning. Scheduling uses requests, not real use. The nodes have idle CPU, but it is promised to other pods, so a large request cannot fit anywhere.
  8. Mitigation. Set the request back to what the app uses, 500m, measured from its metrics. All six pods fit: 1, 1, 4 on nodes a, b, c.
  9. Recovery. All six replicas are ready before the sale starts.
  10. Prevention. Size requests from measured use, add a cluster autoscaler for real growth, and alert on pods Pending for more than a few minutes.
A memory leak puts pods in CrashLoopBackOff
  1. Healthy state. The orders container uses about 416Mi of memory against a 768Mi limit.
  2. Trigger. Release 2.14 caches every order it reads and never lets go, so memory climbs past 900Mi.
  3. What is affected. Every replica, because they all run the same release.
  4. Symptoms. Pods restart again and again; their status turns to CrashLoopBackOff, and requests fail while no pod is ready.
  5. Metrics. Ready drops to 0 of 3; the restart count climbs; memory use rises in a sawtooth that ends at the limit each time.
  6. Logs. kubectl describe pod shows how the last container ended.
    Last State:  Terminated
      Reason:    OOMKilled
      Exit Code: 137
    Warning  BackOff  Back-off restarting failed container
  7. Reasoning. Exit code 137 is 128 plus signal 9: the kernel killed the process because the container went over its memory limit. CPU over a limit only slows a container; memory over a limit ends it.
  8. Mitigation. Roll back to release 2.13, which does not leak, and raise the limit to 1024Mi for headroom while the leak is fixed.
  9. Recovery. Pods stay up: 3 of 3 ready, memory flat at about 416Mi.
  10. Prevention. Load-test each release for memory growth over time, alert on restarts and OOMKilled events, and keep limits based on measured peaks.

Learn it properly

All simulators · Curriculum map