Sub topic 16
Troubleshooting evictions, OOM kills, and preemptions
This chapter assumes you know requests and limits, the three QoS classes, PriorityClass, preemption, and node-pressure eviction from the earlier chapters. It shows how to tell which mechanism removed a Pod, and what to change.
Three removals, three different signals
A Pod can disappear for three separate reasons. Each leaves a different trace.
| Cause | Who acts | Where to look |
|---|---|---|
| OOM kill | Linux kernel, on a container | `lastState.terminated.reason: OOMKilled`, exit code 137 |
| Node-pressure eviction | kubelet, on a whole Pod | Pod `status.reason: Evicted`, message names the resource |
| Preemption | kube-scheduler, to place a higher-priority Pod | `Preempted` event, `nominatedNodeName` on the new Pod |
The key difference: an OOM kill restarts the container inside the same Pod (subject to restartPolicy). An eviction or preemption removes the Pod itself.
Diagnosing OOM kills
Read the container's last state:
kubectl get pod important-app -o jsonpath='{.status.containerStatuses[0].lastState.terminated}{"\n"}'
kubectl describe pod important-app | grep -A5 'Last State'Reason: OOMKilled with exit code 137 means the kernel killed the container. Two cases look the same:
- The container exceeded its own memory limit. The fix is a higher limit or less memory use.
- The node ran out of memory before the kubelet could evict. The kernel then picks victims by
oom_score_adj, so BestEffort and Burstable containers that exceed their requests die first.
Compare the container's limit with its real usage (kubectl top pod) to tell these apart.
Diagnosing evictions
Evicted Pods stay in the API as Failed until cleaned up, so you can inspect them:
kubectl get pods --field-selector=status.phase=Failed
kubectl describe pod <evicted-pod> | grep -iE 'status|reason|message'
kubectl describe node <node> | grep -A8 ConditionsThe message says which signal triggered it, such as memory.available or ephemeral-storage. The node conditions MemoryPressure, DiskPressure, and PIDPressure confirm it. If the evicted Pod was BestEffort or used far more than its requests, the ranking behaved as designed. Set realistic requests, or raise the Pod's priority.
Diagnosing preemption
Preemption shows up on both sides. On the victim:
kubectl get events --field-selector reason=PreemptedOn the Pod that triggered it:
kubectl describe pod important-app | grep -iE 'priority|qos|nominated'A set Nominated Node means the scheduler chose a node and is waiting for victims to terminate. The Pod can stay Pending during the victims' grace period.
If a high-priority Pod stays Pending and nothing is preempted, check these:
- The victims' PodDisruptionBudgets. Preemption tries to respect them but may not.
- Pod affinity or anti-affinity that depends on lower-priority Pods.
- Whether removing every lower-priority Pod on any node would still leave too little room.
preemptionPolicy: Neveron the PriorityClass.
Choosing the fix
- Container
OOMKilledat its limit: raise the memory limit and request. - Evicted for node pressure: set requests close to real usage, and add capacity.
- Important Pod preempted too easily: raise its priority above its neighbors.
- Low-priority work evicting nothing but still Pending: add nodes or reduce requests.
Exercise
A Pod shows Last State: Terminated, Reason: OOMKilled, Exit Code: 137, and the Pod is still present with a rising restart count. Was this an eviction or a preemption? What do you check next?
Show answer
Neither. It is an OOM kill of one container, and the kubelet restarted it in the same Pod. Next, compare the container's memory limit with its actual usage using kubectl top pod. If usage is near the limit, raise the limit. If it is well below the limit, check whether the node ran out of memory, using kubectl describe node.
Exercise
A Pod's kubectl describe output shows Nominated Node: node-2, yet the Pod is Pending. Why can this happen?
Show answer
The scheduler has selected victims on node-2 and is waiting for them to terminate. They are still within their graceful termination period, so the resources are not free yet. The nomination is not a guarantee, and the Pod may be placed elsewhere if the situation changes.