Skip to main content

Pod Priority & Preemption

Key Takeaways for AI & Readers
  • Workload Tiering: Assign different importance levels to Pods using PriorityClasses to ensure critical services remain running.
  • Preemption: When the cluster is at capacity, the scheduler will evict (kill) lower-priority Pods to make room for higher-priority ones.
  • Graceful Termination: Even during preemption, evicting Pods are given a graceful shutdown period to finish tasks or save state.

Not all applications are equal. Your "Database" is likely more important than your "Log Exporter". When a cluster is full, Kubernetes needs to know which pods to keep and which to kill to make room for critical workloads.

1. High-Priority Scheduling

If a pod with a High Priority is scheduled and there is no room, Kubernetes will Preempt (kill) a lower priority pod to make space.

Busy Node (Capacity: 3)
📦
Low
📦
Low
📦
Low
Preemption: When a node is full, the scheduler will kill (preempt) lower-priority pods to make room for PriorityClass: Critical pods.

2. PriorityClasses

You define priorities using a PriorityClass object.

apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: high-priority
value: 1000000
globalDefault: false
description: "Use this for critical backend services."

In your Pod YAML:

spec:
priorityClassName: high-priority

3. Preemption Logic

  1. Scheduler finds a Pod that can't be scheduled.
  2. It looks for nodes where killing lower-priority pods would allow the pending pod to run.
  3. It kills those pods and schedules the new one.

Important: Preempted pods get a graceful termination period, just like any other pod deletion.