Pod Preemption Behavior
You'll learn how Kubernetes automatically evicts lower-priority pods to make room for more important workloads.
The Core Idea
When a high-priority pod can't be scheduled because the cluster lacks resources, Kubernetes doesn't just leave it pending. Instead, the scheduler actively looks for lower-priority pods it can preempt (evict) to free up the necessary resources. This ensures critical workloads get scheduled even when the cluster is under pressure.
Think of it like airport seating: if a premium passenger arrives but all seats are taken by economy passengers, the airline might "bump" lower-tier passengers to accommodate the priority traveler. Kubernetes does the same with pods.
How Preemption Works
When a pod remains unschedulable, the scheduler evaluates:
- Can preemption help? It identifies nodes where evicting lower-priority pods would free enough resources.
- Which pods to evict? It selects the lowest-priority pods first, evicting only what's necessary.
- Graceful termination: Selected pods receive a termination signal and respect their
terminationGracePeriodSeconds. - Scheduling the winner: Once resources are freed, the high-priority pod is scheduled.
Important Behaviors
- Preemption is not immediate: There's a delay while lower-priority pods terminate gracefully.
- No guarantees: Even after preemption starts, the high-priority pod might not schedule if something else grabs the resources first.
- PodDisruptionBudgets are respected: The scheduler won't violate PDBs during preemption when possible.
The scheduler also adds a nominatedNodeName field to the pending pod, indicating where it expects to land once preemption completes.
Key Takeaway:
Pod preemption ensures high-priority workloads get resources by gracefully evicting lower-priority pods, maintaining cluster efficiency while respecting priority hierarchies.