Running workloadsLesson 2 of 14
Requests and limits
Each container declares resources as two values: "I need at least this much" (requests) and "I can never use more than this" (limits). Here we follow how each value is used at placement time and at run time. The detailed way the scheduler filters and picks nodes is in Which Node Gets the Pod (Scheduling).
CPU allocated (example)—
web CPU / limit250m requested
web memory / limit256Mi requested
web statusnone
RequestAppears in a later step
What you will learn
- Requests are a reservation; limits are a hard line
- The scheduler looks at request totals, not usage
- Hitting the CPU limit slows you down; hitting the memory limit kills you
- What happens with empty requests, and QoS classes
Myths and facts
| Myth | Fact |
|---|---|
| Low usage means there is room for a pod | The scheduler only looks at request totals. When allocation is full, it is Pending regardless of usage |
| Going over the limit kills the container, CPU or memory | CPU is only slowed (throttling); only memory is killed (OOMKilled) |
| Requests can be left empty | Placement goes wrong, creation is rejected in namespaces with quotas, and the HPA cannot compute utilization |
| HPA CPU 80% means 80% of the limit | It is measured against requests |
| Generous requests are safer | Pods fail to place even with room, and resources are wasted |
Try it yourself
kubectl get pod <pod> -o jsonpath='{.spec.containers[*].resources}' # Requests and limits
kubectl get pod <pod> -o jsonpath='{.status.qosClass}' # QoS class (eviction order)
kubectl top pod # Actual usage (needs metrics-server)
kubectl describe node <node> | grep -A 8 'Allocated resources' # Request totals on the node
kubectl get pod <pod> -o jsonpath='{.status.containerStatuses[*].lastState.terminated.reason}' # OOMKilled?
Check yourself
Further reading: Resource management for Pods and containers · Kubernetes scheduler · Configure Quality of Service for Pods · Which Node Gets the Pod (Scheduling)