Kubernetes · Concept
Requests, limits, QoS and eviction
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
Explain requests and limits for CPU and memory in Kubernetes. What are the three QoS classes, and what's the difference between a pod being OOMKilled and a pod being evicted?
Then
Follow-ups the interviewer asks next
- Which one does the scheduler use?
- What happens when a container goes over its CPU limit, and over its memory limit?
- Which pods go first when a node runs low on memory?
- Can you change a pod's CPU or memory without restarting it?
- How do LimitRange and ResourceQuota help?
- How would you choose numbers for a new service?
The answer
What a strong answer covers
- Requests: what the scheduler reserves on a node, and each pod's share of CPU under contention. Limits: the hard ceiling, enforced by cgroups.
- Over the CPU limit → throttled (slower, not killed). Over the memory limit → the kernel kills the container:
OOMKilled, exit code 137, then a restart. - QoS classes: Guaranteed (every container's requests equal its limits for CPU and memory), Burstable (some requests set), BestEffort (none). Under node memory pressure the kubelet evicts BestEffort pods first, then Burstable pods using most above their requests, Guaranteed last.
- Eviction: the kubelet removes a pod because the node is short of memory, disk or PIDs; the pod shows
Evictedand its controller recreates it elsewhere. OOMKilled: one container went over its own limit (or the kernel acted for the whole node because the kubelet was too slow). - In-place resize: since 1.35 (stable) a running pod's CPU and memory can be changed through the
resizesubresource without a restart, with some rules for lowering memory; VPA has anInPlaceOrRecreatemode. - Kubernetes 1.37 turns memory QoS on by default (beta, cgroup v2):
memory.highthrottles a container before the hard kill. - LimitRange: per-container defaults and min/max in a namespace. ResourceQuota: the namespace's total.
- Numbers: from load tests and production usage (p95 plus headroom); memory limit equal to the request for predictable services; revisit with VPA recommendations.
The red pen
Common traps
Avoid:"the scheduler uses actual usage"; "going over the CPU limit gets the pod killed"; treating eviction and OOMKilled as the same thing.
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.