Interview Prep/Kubernetes/Resources, OOM, probes and termination

`kubectl describe pod` shows `Last State: Terminated, Reason: OOMKilled, Exit Code: 137`.

BeginnerTroubleshootingResources, OOM, probes and termination
Answer

Likely causes → The container exceeded its memory limit and the kernel cgroup OOM killer ended it. Causes: limit too low for normal load, a memory leak, a traffic spike, or a runtime that sizes itself from host memory instead of the cgroup.

Diagnose →

kubectl get pod api-x -o jsonpath='{.spec.containers[0].resources}'
kubectl top pod api-x --containers
# Prometheus: container_memory_working_set_bytes{pod="api-x"} vs the limit over 24h

Fix → If usage grows steadily until the kill, it is a leak: take a heap dump and fix the code. If it plateaus just above the limit, raise the limit (and the request) to observed peak plus 20–30%.

Prevent → Alert when working set exceeds 85% of the limit; set requests equal to limits for memory on critical services so the scheduler reserves what they really use.

All Kubernetes questions Roadmap: Kubernetes core

More on Resources, OOM, probes and termination