Appearance

Requests, limits, and QoS

Use CPU and memory requests to plan placement, then see what happens when a container reaches each limit.

What you will understand

  • Read CPU and memory quantities in a Pod specification.
  • Distinguish scheduling based on requests from runtime CPU throttling and memory failure.
  • Predict the QoS class of the example Pod and inspect the value Kubernetes assigned.

Builds on: Your first debugging workflow

How requests and limits affect a Pod

A web container uses little CPU between requests and bursts when a page is loaded. A second container holds a large cache in memory. Kubernetes needs to know how much room to plan for before either container starts. A resource request is the amount the scheduler accounts for when it places a Pod. It compares requests already assigned to a node, plus those of the incoming Pod, with the node’s allocatable resources. A node can appear idle and still lack room on that calculation.

A resource limit constrains what a container can use at runtime. Setting a CPU limit slows the process when it has used its CPU time budget for an interval. This is throttling. At a memory limit, the kernel can kill a process that cannot complete an allocation within the memory boundary. The kubelet may restart the container. In the scene, compare the placement decision with the consequences of exceeding the two limits.

How requests and limits change what happens

Requests determine whether a Pod fits on a node. A CPU limit can slow the process, while exceeding a memory limit can end it.

  1. Compare requests with allocatable capacity

    Node A has only 100m of its scheduling budget left; low observed CPU usage cannot make the 200m request fit.

  2. Place the Pod on an eligible worker

    Node B has 500m unrequested, so this resource check passes and the scheduler may bind the Pod there.

  3. CPU demand is throttled

    A bound container may burst above its request. Sustained demand beyond its CPU limit can be throttled by the runtime boundary.

  4. Memory allocation can trigger a kill

    A memory limit is a separate boundary. An allocation that cannot be satisfied within the cgroup may trigger an OOM kill.

Single ordinary container on Linux; reservations and init-container accounting are omitted.

Try the mechanism with your own inputs
Bind to worker-aFits 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.. Requested Pod, 1 CPU, active. worker-a, 2 CPU unreserved · no GPU, ready. worker-b, 1 CPU unreserved · GPU label, idleRequested Pod: 1 CPU
Requested Pod1 CPUIn focus
worker-a: 2 CPU unreserved · no GPU
worker-a2 CPU unreserved · no GPUReady
worker-b: 1 CPU unreserved · GPU label
worker-b1 CPU unreserved · GPU labelContext
Requested Pod1 CPUIn focus
worker-a2 CPU unreserved · no GPUReady
worker-b1 CPU unreserved · GPU labelContext
Bind to worker-a

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.
Inspect YAML or commands

Filter by requests

kubectl describe pod resource-demo

Throttle CPU demand

limits:
  cpu: 500m

Memory allocation fails

limits:
  memory: 128Mi
Explore another case

Read CPU and memory quantities

Save the manifest as resource-demo.yaml. 100m is 100 millicores, one tenth of a CPU. With a request of 100m and a limit of 500m, the scheduler accounts for one tenth and the container can use up to half a CPU on average under its CPU quota. 64Mi means 64 mebibytes. The memory request affects placement while the 128Mi limit bounds the container’s memory use.

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.

Kubernetes assigns a Quality of Service (QoS) class. In the container-level model shown here, Guaranteed requires all containers to have positive CPU and memory requests equal to their limits for each resource. BestEffort applies when containers have neither CPU nor memory requests or limits, and Burstable covers this example because the values differ. Change the fields in the second scene and compare the class.

Recognize the resource configuration behind each QoS class

QoS describes resource configuration, and the kubelet considers usage and priority when it must evict Pods under pressure.

  1. Guaranteed requests and limits

    • Guaranteed PodEvery CPU/memory request equals its limit
    • Burstable PodCPU/memory request or limit set; Guaranteed rule fails
    • BestEffort PodNo CPU/memory requests or limits
    • Node pressurePriority and usage relative to requests matter
    • Own memory limitCan still kill a Guaranteed container

    Both resource pairs must be present and equal for every container in this simplified configuration.

  2. Burstable requests and limits

    • Guaranteed PodEvery CPU/memory request equals its limit
    • Burstable PodCPU/memory request or limit set; Guaranteed rule fails
    • BestEffort PodNo CPU/memory requests or limits
    • Node pressurePriority and usage relative to requests matter
    • Own memory limitCan still kill a Guaranteed container

    Different request and limit values make this example Burstable; it can consume spare CPU within its runtime boundary.

  3. BestEffort has no resource requests

    A Pod without these requests and limits is BestEffort. It has no such scheduler reservation and can be vulnerable under pressure.

  4. Node pressure and eviction

    Eviction evaluates pressure signals, priority and usage relative to requests. A class is useful context rather than immunity.

Uses ordinary per-container CPU and memory fields; QoS is not a complete eviction algorithm.

Inspect YAML or commands

Guaranteed is configuration

requests: {cpu: 250m, memory: 128Mi}
limits: {cpu: 250m, memory: 128Mi}

Burstable can use spare CPU

requests: {cpu: 100m, memory: 64Mi}
limits: {cpu: 500m, memory: 128Mi}
Explore another case

Inspect what Kubernetes admitted

Apply the example and inspect the class and accepted spec. kubectl top reports recent usage through a separately installed metrics pipeline. If the Metrics API is absent, the request and limit values remain visible on the Pod. Compare them with node allocatable capacity and with usage if metrics are available.

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

Follow the resource and scheduling lab to see how a Pod can stay pending when its request exceeds available capacity.

Distinguish a memory limit from node pressure

QoS is one signal for understanding how Pods behave under pressure. Under node memory pressure, the kubelet considers whether usage exceeds requests, Pod Priority, and the amount by which usage exceeds requests. A container can also hit its own memory limit while the node has ample free memory. Use Pod events and the last container state to tell those failures apart.

Check your understanding

A Pod requests 2 CPUs. A node reports low current CPU usage but has only 1 CPU left after existing requests. Can the Pod fit there?

The node fails the resource fit check. The scheduler accounts for requests against allocatable capacity. Moving the workload, reducing a justified request, or adding capacity can change the result.

Primary documentation

Go to the source

Reviewed 2026-10-27 · Kubernetes 1.37 · Related local exercise

Search the book

Search loads when you open it.

Keyboard shortcuts

Ctrl + K / ⌘ + K
Search the book
?
Open this guide
Tab / Shift + Tab
Move between controls
Enter / Space
Activate a focused button or disclosure
← / →
Focused visual timeline · previous or next step
Home / End
Focused visual timeline · first or last point
Esc
Close the open dialog or menu