Pod Priority and Preemption
An important Pod arrives on a full cluster with no room on any Node, and soon a less important Pod is gone from one of them. Who chose that victim, and does the newcomer always get the room that was freed?
Play the animation 5 steps, animated, plays on a computer or a tablet
Pod Priority and Preemption, step by step
-
Pod NEW arrives at the API. The Priority admission plugin resolves spec.priorityClassName to a number, 2000000000 for system-cluster-critical, and writes it into spec.priority. If the Pod sets a different spec.priority, the plugin rejects it. So while the plugin is enabled, as it is by default, PriorityClass is the only route. The other built-in class, system-node-critical, is slightly higher.
Play from step 1 -
Scheduler takes Pod NEW off its queue and runs a scheduling cycle. Filter plugins drop every Node failing a predicate (taints, ports, requests against allocatable), and here all of them fail on capacity. But before that failure is recorded, the default preemptionPolicy=PreemptLowerPriority opens preemption mode. A class set to Never would leave Pod NEW queued as Unschedulable.
Play from step 2 -
Scheduler scans the running Pods on candidate Nodes for a minimal victim set whose deletion lets Pod NEW fit. Every victim has strictly lower priority, and the more important are reprieved first. Pod A at 100 is enough alone, since its freed 1 CPU and 1Gi memory match the Pod NEW requests. Pod B at 1000, the most important candidate, is reprieved first. Pod C ties at 100 but started earlier, so it is tried before Pod A and kept.
Play from step 3 -
Scheduler patches Pod A with a DisruptionTarget condition, reason PreemptionByScheduler, then sends a standard DELETE, not an eviction. So PodDisruptionBudget gates are bypassed, though victim choice prefers PDB-friendly sets. Pod A enters Terminating with preStop and SIGTERM, then SIGKILL if it outlives its grace period. In a separate status write Pod NEW is marked Unschedulable with status.nominatedNodeName=Node-1, reserved but not guaranteed: a higher priority Pod can still take it.
Play from step 4 -
Pod A exited gracefully, its capacity back on Node-1. Scheduler retries Pod NEW on its nominated Node first. Filter passes, and Pod NEW binds to Node-1. The controller owning Pod A creates a replacement, scheduled elsewhere or left Pending. This is not node-pressure eviction, covered separately, where Kubelet ranks by over-request first, then Priority, then how far each is over.
Play from step 5