Why Do Kubernetes Pods Get Evicted? Understanding Preemption, QoS, and Node Pressure
This article explains why Kubernetes pods are evicted, covering preemption, node‑pressure eviction, pod scheduling, priority classes, QoS tiers, other eviction methods, and how to monitor evictions with Prometheus, providing practical examples and command‑line snippets.
What Does It Mean When a Kubernetes Pod Is Evicted?
Pods are terminated, usually because there are not enough resources. The eviction process is the termination of a pod assigned to a node.
Reasons for Pod Eviction: Preemption and Node Pressure
One common case is Preemption : when a new pod needs to be scheduled on a resource‑constrained node, the scheduler may evict lower‑priority pods to free resources.
Kubernetes continuously checks node resources and evicts pods when necessary; this is called node‑pressure eviction .
Preemptive Eviction
If no suitable node has enough resources for a new pod, the kube-scheduler evicts lower‑priority pods to make room.
Pod Scheduling
Scheduling assigns pods to nodes. The kube-scheduler runs in the control plane, keeping pods in Pending state until a matching node is found. The scheduling process consists of:
Filtering
Scoring
Filtering
During filtering, the scheduler selects all nodes where the pod could be placed, considering taints, tolerations, and other constraints.
Scoring
In the scoring step, each candidate node receives a score; the highest‑scoring node is chosen. Ties are broken randomly.
If no node can accommodate the pod, the scheduler initiates preemption, evicting lower‑priority pods to schedule the new one.
Pod Priority
Priority Classes let you assign numeric priority values to pods, making higher‑priority pods less likely to be evicted.
$ kubectl get priorityclasses
$ kubectl get pc
NAME VALUE GLOBAL-DEFAULT AGE
system-cluster-critical 2000000000 false 2d
system-node-critical 2000001000 false 2dPriority Example
Three pods represent blueberry, raspberry, and strawberry. Two priority classes are defined:
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: trueberry
value: 1000000
globalDefault: false
description: "This fruit is a true berry"
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: falseberry
value: 5000
globalDefault: false
description: "This fruit is a false berry"Blueberry gets trueberry (value = 1000000)
Raspberry and strawberry get falseberry (value = 5000)
When new high‑priority pods are created, lower‑priority pods (raspberry, strawberry) are evicted to free resources.
priorityClassName: trueberryNode‑Pressure Eviction
Kubernetes monitors node resources such as CPU, memory, and disk. When usage exceeds defined thresholds, the kubelet evicts pods based on their QoS class.
QoS Classes
Guaranteed
Burstable
BestEffort
QoS is determined by the pod’s CPU and memory limits and requests.
Guaranteed
All containers set both limits and requests.
CPU limits equal CPU requests.
Memory limits equal memory requests.
Guaranteed pods are rarely evicted.
Burstable
Not Guaranteed.
At least one container has a limit or request.
Burstable pods can be evicted, but less likely than BestEffort.
BestEffort
No container sets limits or requests.
BestEffort pods are the most likely to be evicted under node pressure.
Kubelet evicts pods in this order:
BestEffort or Burstable pods that exceed their requests.
Burstable pods below requests or Guaranteed pods.
Other Eviction Types
API‑Driven Eviction
You can request eviction via the Kubernetes Eviction API.
Taint‑Based Eviction
Applying a NoExecute taint to a node evicts pods that do not tolerate it.
Node‑Level Drain
Commands kubectl cordon and kubectl drain prevent new pods and evict existing pods from a node.
Monitoring Pod Evictions with Prometheus
Use the following query to see evicted pods:
kube_pod_status_reason{reason="Evicted"} > 0Combine with kube_pod_status_phase{phase="Failed"} to identify pods that failed before eviction.
Conclusion
During preemption, Kubernetes evicts lower‑priority pods to schedule new ones, using Priority Classes to control eviction likelihood. Node‑pressure eviction respects QoS classes, allowing you to protect critical workloads by configuring appropriate limits, requests, and priorities.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
