Course contentsShow
← Cloud and Infrastructure
Lesson 1371 of 2,98927. Kubernetes Scheduling and ResourcesFree lesson

Pod Preemption Behavior

Learn how the scheduler evicts lower-priority pods to make room for higher-priority pending pods.

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:

  1. Can preemption help? It identifies nodes where evicting lower-priority pods would free enough resources.
  2. Which pods to evict? It selects the lowest-priority pods first, evicting only what's necessary.
  3. Graceful termination: Selected pods receive a termination signal and respect their terminationGracePeriodSeconds.
  4. 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.