What it means
Each container's memory limit is enforced by the kernel. Going over it doesn't slow the container down, it kills it: the Pod shows Reason OOMKilled and exit code 137 (128 + signal 9), and the kubelet restarts it.
Causes and fixes
Most likely first. Run the check, and if it matches, apply the fix.
1. The limit is below what the app needs at peak
Check:
kubectl describe pod <pod> | grep -B2 -A4 'Last State'
kubectl top pod <pod>
Fix: Set the limit above observed peak usage with headroom; set requests near normal usage.
2. A memory leak, or a cache with no bound
Check:
kubectl top pod <pod> --containers # grows steadily until killed
Fix: Bound caches and fix the leak; for JVM or Node apps, set the heap size below the container limit.
3. The runtime ignores the container limit (an old JVM sizing its heap from the node's memory)
Check:
kubectl exec <pod> -- java -XX:+PrintFlagsFinal -version | grep MaxHeapSize
Fix: Use a container-aware runtime or set -Xmx (or MaxRAMPercentage) explicitly.
Fix it yourself
A live machine in your browser with this problem already on it. The grader checks the result.
Open the labNo account needed for your first tries.
Related errors
- CrashLoopBackOff
A container keeps exiting, and Kubernetes waits longer and longer before restarting it.
- Out of memory: Killed process
The system ran out of memory and the kernel killed the process using the most.