Requests, limits, and QoS
Connect scheduler accounting to CPU throttling, memory failure, and eviction priority.
What you will understand
- Predict scheduling from requests rather than observed usage
- Distinguish CPU throttling from memory limit failure
- Classify a Pod using QoS rules and their limits
Builds on: Your first debugging workflow
Mental model: admission, placement, and runtime answer different questions
A resource request is the amount Kubernetes uses when deciding whether a node has room for a Pod. It is not the Pod’s current usage. A resource limit constrains consumption at runtime through the node’s container runtime and operating system. A Pod requesting 250 millicores can use more CPU when capacity and its limit permit. The scheduler does not continually move it because usage changes. This distinction explains why a mostly idle cluster can still have Pending Pods: existing requests may already account for the allocatable capacity on every suitable node.
CPU is divisible execution time. 250m means one quarter of one CPU unit; it does not pin a thread to a particular core. Memory quantities such as 128Mi are bytes with binary suffixes. Node allocatable capacity excludes reservations and other node overhead from the capacity available for Pods. For ordinary containers, the scheduler considers their requests together, with additional rules for init containers and Pod overhead. Read the admitted Pod because defaults or admission mutation can change the submitted configuration.
A scheduling budget is not a usage meter
Trace a 200m request against allocatable CPU and then follow runtime CPU and memory enforcement.
Node A has only 100m of its scheduling budget left; low observed CPU usage cannot make the 200m request fit.
- New Pod blocked toward Node A200m > 100m
Inspect this state in YAML / kubectl
kubectl describe pod resource-demoRead the complete visual sequence
- Filter by requests
Node A has only 100m of its scheduling budget left; low observed CPU usage cannot make the 200m request fit.
- Bind to Node B
Node B has 500m unrequested, so this resource check passes and the scheduler may bind the Pod there.
- Throttle CPU demand
A bound container may burst above its request. Sustained demand beyond its CPU limit can be throttled by the runtime boundary.
- Memory allocation fails
A memory limit is a separate boundary. An allocation that cannot be satisfied within the cgroup may trigger an OOM kill.
No node fits
Both suitable nodes have less than 200m unrequested CPU.
- Budget exhausted
Existing admitted requests consume the placement budget on both nodes.
- Pending is expected
The scheduler does not launch a container on an unsuitable node, so no runtime CPU limit can repair this placement failure.
- Repair the right boundary
Add suitable capacity or deliberately revise requests; changing only a limit does not make the 200m request fit.
About this model
Single ordinary container on Linux; reservations and init-container accounting are omitted.
Try the mechanism with your own inputs
- Requested Pod to worker-afits request
Fits requested resources and constraints. This model picks the first feasible example node; Kubernetes also scores feasible nodes before binding. Available CPU means allocatable capacity minus requests, not current usage. The GPU label constrains placement only; it does not allocate a GPU device.
# Pod spec fragment; example nodes carry accelerator labels.
spec:
containers:
- name: web
image: nginx:1.28.0-alpine
resources:
requests:
cpu: "1"
limits:
cpu: "4"
# The limit stays fixed; GPU allocation needs a device resource, not just a label.Walkthrough: the same request has two different runtime outcomes
This complete Pod uses one small container. The image is a training convenience; use an approved immutable image identifier for a reproducible release. Apply it in the disposable namespace created by the module lab.
apiVersion: v1
kind: Pod
metadata:
name: resource-demo
spec:
containers:
- name: web
image: nginx:1.27-alpine
resources:
requests:
cpu: 100m # Scheduling accounts for 0.1 CPU.
memory: 64Mi # A reservation input, not measured usage.
limits:
cpu: 500m # Runtime may throttle sustained CPU demand.
memory: 128Mi # Exceeding available limit can trigger OOM.
A CPU limit normally causes throttling when the container exhausts its allowed CPU time over an accounting period. Work slows down; the process is not normally killed merely for requesting additional CPU time. A memory limit cannot make memory reclaimable when an application keeps using it. The kernel may kill a process when the cgroup cannot satisfy an allocation within its memory constraints. A terminated container can report OOMKilled; inspect termination reason and events before assuming every exit code 137 is the same failure. A restarting process may recreate caches and repeat the failure indefinitely.
Quality of Service, or QoS, groups Pods according to resource configuration. In the standard container resource model, Guaranteed requires CPU and memory requests and limits for every container, with each request equal to its corresponding limit. BestEffort has none of those requests or limits. Burstable includes configurations between those extremes. The example is Burstable. Its class is a classification of configuration, not a measured promise of latency or immunity from failure.
Classify configuration before diagnosing pressure
Compare Guaranteed, Burstable and BestEffort configuration and their relationship to node pressure.
Both resource pairs must be present and equal for every container in this simplified configuration.
Inspect this state in YAML / kubectl
requests: {cpu: 250m, memory: 128Mi}
limits: {cpu: 250m, memory: 128Mi}Read the complete visual sequence
- Guaranteed is configuration
Both resource pairs must be present and equal for every container in this simplified configuration.
- Burstable can use spare CPU
Different request and limit values make this example Burstable; it can consume spare CPU within its runtime boundary.
- BestEffort has no resource floor
A Pod without these requests and limits is BestEffort. It has no such scheduler reservation and can be vulnerable under pressure.
- Pressure is more than class
Eviction evaluates pressure signals, priority and usage relative to requests. A class is useful context rather than immunity.
Guaranteed still OOMs
A Guaranteed container exceeds its own memory limit.
- Reservation admitted
Matching request and limit values classify the Pod as Guaranteed.
- Own limit reached
The memory limit still applies to this container; QoS does not enlarge it.
- Inspect termination
An OOMKilled last state and restart count explain runtime failure without changing the QoS classification.
About this model
Uses ordinary per-container CPU and memory fields; QoS is not a complete eviction algorithm.
Practice: observe the admitted object and its boundary
kubectl apply -f resource-demo.yaml
kubectl get pod resource-demo -o jsonpath='{.status.qosClass}{"\n"}'
kubectl describe pod resource-demo
kubectl get nodes -o custom-columns=NAME:.metadata.name,CPU:.status.allocatable.cpu,MEMORY:.status.allocatable.memory
# Requires the separately installed resource metrics pipeline.
kubectl top pod resource-demo
Expect the class to be Burstable, assuming admission has not changed the Pod. kubectl top may fail on a local cluster without Metrics Server; the API object and scheduling events remain useful without that add-on. Compare requested resources to measured consumption without treating either as a substitute for the other. The node description’s allocated resources section summarizes requests from assigned Pods, which is closer to scheduler capacity accounting than a single usage sample.
In a disposable namespace, change both resource pairs to equal values in a new Pod manifest and compare its class. Do not expect editing immutable Pod fields in place to perform a replacement automatically. Create a different named Pod or use a Deployment when practicing configuration changes. Remove the examples after recording their admitted settings and observed status.
Pitfalls: QoS is part of a larger pressure story
Node-pressure eviction considers the scarce resource, whether usage exceeds requests, Pod priority, and usage relative to requests. “BestEffort first, Guaranteed never” is an unsafe universal rule. A Guaranteed Pod can still fail from its own memory limit, infrastructure loss, or severe pressure. A high memory request also reduces placement options, so increasing it without measuring a working set may trade restarts for Pending Pods. CPU requests influence relative CPU allocation under contention; they do not buy a dedicated physical processor by themselves.
Check your understanding
A node has 2 allocatable CPUs, 1.9 CPUs already requested, and only 5 percent actual usage. Can a new 200m request fit?
No. The remaining scheduling budget is 100m, so this node fails the CPU request check even though current usage is low. Lowering the new Pod’s CPU limit would not change that request calculation. Investigate overestimated requests or add appropriate capacity, then evaluate runtime behavior under load before settling on new requests.
The placement and resources lab demonstrates a deliberately impossible node selector and reports the admitted QoS class. Resource exhaustion and runtime throttling are separate extensions using the examples in this lesson. Next, add a placement constraint and predict why a Pod that fits numerically can still remain Pending.
Primary documentation
Go to the source
Reviewed 2026-10-27 · Kubernetes 1.37 · Related local exercise