K8s by Example: Resource Requests & Limits
| Requests define the minimum resources a Pod needs. Limits define the maximum it can use. The scheduler uses requests to place Pods on nodes. |
| pod-resources.yaml | |
| Resources are defined per container. | |
| pod-resources-safe.yaml | |
| CPU is compressible: exceeding limit causes throttling. Memory is incompressible: exceeding limit causes OOMKill. Set memory limits equal to requests to avoid OOMKill surprises. | |
| resource-units.yaml | |
| CPU units: | |
| qos-classes.yaml | |
| QoS classes are assigned based on requests and limits. | |
| limit-range.yaml | |
| LimitRange sets default, min, and max resources per namespace. Applied automatically to Pods without explicit resources. Prevents runaway resource consumption. | |
| terminal | |
| Node allocatable is capacity minus system reserved. Scheduler only considers allocatable when placing Pods. Sum of Pod requests must be less than node allocatable. | |
| terminal | |
| Eviction happens when node resources run low. Kubelet evicts Pods based on QoS class and resource usage. BestEffort first, then Burstable exceeding requests, finally Guaranteed. | |
| terminal | |
| Debug resource issues by checking actual usage vs requests. Requires metrics-server. OOMKilled containers show exit code 137. High CPU throttling means limit is too low. | |