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

A Pod was OOMKilled, but `container_memory_usage_bytes` was well below the limit.

AdvancedTroubleshootingResources, OOM, probes and termination
Answer

Likely causes → You watched the wrong metric or the wrong resolution. usage_bytes includes reclaimable page cache; the OOM decision follows the working set and spikes faster than a 30s scrape. Also, memory used by emptyDir with medium: Memory (tmpfs) counts against the container limit.

Diagnose →

max_over_time(container_memory_working_set_bytes{pod="api-x",container="app"}[10m])
kubectl get pod api-x -o jsonpath='{.spec.volumes}' | jq '.[] | select(.emptyDir.medium=="Memory")'

Fix → Size limits from working_set maximums, set sizeLimit on memory-backed emptyDirs, and use shorter scrape intervals for bursty services.

Prevent → Standardise memory dashboards on working set and kube_pod_container_status_last_terminated_reason.

All Kubernetes questions Roadmap: Kubernetes core

More on Resources, OOM, probes and termination