Kubernetes internalsLesson 12 of 12
Priority and Preemption
When nodes are full, a new Pod usually waits in Pending (Which Node Gets the Pod (Scheduling)). But what if it is an important Pod that must not wait? Let's follow priority and preemption, which decide who to keep alive first when resources run short.
paymentPending
batch-aRunning
node-1 free room0
RequestResponse / reportWatchAppears in a later step
What you will learn
- Priority is a number; higher goes first
- Only lower-priority Pods can be preempted
- Preemption honors PDBs only on a best-effort basis
- How an evicted Pod shuts down and goes Pending
- Why system components get the highest priority
Drain vs preemption
| Drain (emptying a node) | Preemption | |
|---|---|---|
| Who starts it | An operator | The scheduler |
| Why | Node maintenance or upgrade | Making room for a higher-priority Pod |
| If it would violate a PDB | Refuses and waits | Proceeds anyway if there is no other way |
| Evicted Pods | Recreated on other nodes | Recreated by the controller, but Pending if no room |
The details of drain and PDBs are in Draining Nodes and Upgrading the Cluster.
Try it yourself
kubectl get priorityclasses # Grades and values, including system-*
kubectl get pods -A -o custom-columns=NAME:.metadata.name,CLASS:.spec.priorityClassName,PRIORITY:.spec.priority # Grade each Pod uses
kubectl get events -A --field-selector reason=Preempted # Pods evicted by preemption
kubectl get pod <pod> -o jsonpath='{.status.nominatedNodeName}' # Node the waiting Pod is headed for
kubectl get pdb -A # Disruption budgets (best-effort only)
Check yourself
Further reading: Pod priority and preemption · Disruptions