Kubernetes Requests vs. Limits & Avoiding OOMKill
The Kubernetes scheduler places pods strictly using requests against each node's Allocatable capacity (Node Capacity minus OS, kubelet, and eviction-threshold reservations, plus the default 110 pods/node kubelet cap). Runtime enforcement uses limits via Linux cgroups.
- CPU Is Compressible, Memory Is Not: Exceeding a CPU limit causes CFS throttling (latency spikes), whereas exceeding a memory limit triggers immediate kernel
OOMKilled(exit code 137). For stateful or JVM/Python services, setting memoryrequest == limit(Guaranteed QoS class) prevents unexpected node eviction. - MiB (
Mi) vs. MB (M): Kubernetes distinguishes binary mebibytes (1 Mi = 1,048,576 bytes) from decimal megabytes (1 M = 1,000,000 bytes). Always standardize onMi/Giacross manifests to match Linux kernel memory accounting. - Plan for N+1 Node Redundancy: Add at least 1 extra node above the calculated minimum so rolling upgrades or single-node failures never stall scheduling.
Frequently Asked Questions
What does 500m CPU mean in Kubernetes?
1000m (millicores) equals 1 full vCPU core / hardware hyperthread. Thus 500m requests half a vCPU core, and 250m requests one-quarter of a core.