Evicted pods: the kubelet stopped them to protect the node

Reproduced on k3s v1.31.5 (k3d) with kubectl v1.36.1.

What you see

$ kubectl get pod evict-demo -n lab
NAME         READY   STATUS   RESTARTS   AGE
evict-demo   0/1     Error    0          2m35s

$ kubectl get pod evict-demo -n lab -o jsonpath='{.status.phase}{" "}{.status.reason}{": "}{.status.message}'
Failed Evicted: Pod ephemeral local storage usage exceeds the total limit of containers 20Mi.

$ kubectl get events -n lab --field-selector involvedObject.name=evict-demo --sort-by=.lastTimestamp
LAST SEEN   TYPE      REASON      OBJECT           MESSAGE
2m29s       Normal    Started     pod/evict-demo   Started container app
2m10s       Warning   Evicted     pod/evict-demo   Pod ephemeral local storage usage exceeds the total limit of containers 20Mi.
2m10s       Normal    Killing     pod/evict-demo   Stopping container app

What it means

The kubelet watches the node's free memory, disk and process IDs. When one drops below an eviction threshold, it stops pods to get the resource back. It also evicts a single pod that goes over its own ephemeral-storage limit.

Evicted pods are not restarted in place. Their controller creates a replacement, maybe on another node. The old pod object stays in Failed phase until someone deletes it or the cluster's garbage collection threshold is reached.

In our lab, kubectl v1.36 printed STATUS Error for the evicted pod, not Evicted. The word Evicted was only in .status.reason. Do not rely on the STATUS column to find evictions.

Common causes

Pod went over its ephemeral-storage limit

Container logs, writable layer files and emptyDir volumes all count toward ephemeral storage. Writing past the limit gets the pod evicted.

How to tell: The message says Pod ephemeral local storage usage exceeds the total limit of containers.

Node memory pressure

The node's available memory fell below the kubelet threshold. Pods using more than their memory request are evicted first.

How to tell: The message says The node was low on resource: memory. The node shows MemoryPressure.

Node disk pressure

The node's root or image file system is nearly full, often from logs, images or emptyDir data. The kubelet first cleans unused images, then evicts pods.

How to tell: The message says The node was low on resource: ephemeral-storage. The node shows DiskPressure.

Too many processes on the node

A pod forking without limit uses up process IDs on the node.

How to tell: The message mentions pids. The node shows PIDPressure.

How to diagnose it

  1. kubectl get pods -n <namespace> --field-selector=status.phase=Failed

    Lists failed pods, which includes evicted ones. Check the reason of each with the next command.

  2. kubectl get pod <pod> -n <namespace> -o jsonpath='{.status.reason}{" "}{.status.message}'

    The message names the resource: memory, ephemeral-storage, pids or the pod's own storage limit.

  3. kubectl get events -A --field-selector reason=Evicted --sort-by=.lastTimestamp

    Shows recent evictions across the cluster. Many evictions on one node point to that node, not to one app.

  4. kubectl describe node <node>

    Check Conditions for MemoryPressure, DiskPressure and PIDPressure. Also check for node.kubernetes.io pressure taints.

  5. kubectl get pod <pod> -n <namespace> -o jsonpath='{.status.qosClass}'

    BestEffort pods, with no requests, are first in line under memory pressure. Burstable pods over their requests come next.

How to fix it

Set ephemeral-storage requests and limits

Give pods that write temp files a realistic ephemeral-storage request and limit. Move large scratch data to a PersistentVolume.

resources:
  requests:
    ephemeral-storage: 1Gi
  limits:
    ephemeral-storage: 2Gi

Trade-off: A limit that is too tight evicts healthy pods, as in our lab. Measure first. A PersistentVolume adds cost and attach time.

Set memory requests close to real use

Pods whose usage is above their request are evicted first. Raising the request moves them back in the line and makes the scheduler pack nodes less tightly.

Trade-off: Higher requests mean fewer pods per node and possibly more nodes.

Free up the node

Rotate container logs, remove unused images and find the pod filling the disk. Then let the node recover from pressure.

Trade-off: This is a one-time cleanup. It will come back unless the source of the growth is fixed.

Clean up old evicted pods

Delete Failed pods once you have read their reason.

kubectl delete pods -n <namespace> --field-selector=status.phase=Failed

Trade-off: You lose the evidence in the pod object. Save the reason and message first if you need them.

How to stop it coming back

  • Set memory and ephemeral-storage requests on every workload so nothing runs as BestEffort by accident.
  • Alert on node MemoryPressure and DiskPressure conditions, not just on evicted pods.
  • Write logs to stdout and let the node rotate them, instead of writing log files inside the container.
  • Use PodDisruptionBudgets and several replicas so an eviction does not take a service down. Note that node-pressure evictions do not respect PodDisruptionBudgets.

How KubeGraf investigates it

Specialist agents pull the logs, events, metrics, workloads and recent deploys for the failing workload into one view. How KubeGraf handles Kubernetes incidents.

Frequently asked questions

What does The node was low on resource: memory mean?

The node's available memory fell below the kubelet's eviction threshold. Pods using more than their memory request are evicted first. Setting requests close to real use moves a pod back in that line.

What is ephemeral-storage eviction?

Container logs, writable layer files and emptyDir volumes count as ephemeral storage. A pod that writes past its ephemeral-storage limit is evicted. Move large scratch data to a PersistentVolume.

What does DiskPressure mean for my pods?

The node's disk is nearly full. The kubelet first removes unused images and then evicts pods to get space back. The node also stops taking new pods until the pressure clears.

Are evicted pods restarted?

No. The controller creates a replacement pod, maybe on another node. The old pod stays in Failed phase until someone deletes it.

Last updated . Try KubeGraf Freemium.

Related

Kubernetes documentation