When a cluster runs out of room, the scheduler does not decide what matters — it reads a single integer on each pod. A PriorityClass is how you put a meaningful number there, and preemption is what the scheduler does with it: if a pending pod outranks pods already running on a node, the scheduler picks the cheapest set of them to delete, records that node as the pod’s nominated node, and evicts the victims through normal graceful termination. This guide covers creating priority classes, the built-in system classes and the value ceiling, exactly how victims get chosen, how PodDisruptionBudgets and grace periods change the outcome, and why giving everything high priority puts you back where you started.
What you’ll accomplish
- Create a
PriorityClasswith a deliberatevalue, and a non-preempting one withpreemptionPolicy: Never. - Understand how
spec.priorityClassNamebecomes the immutablespec.priorityon a pod. - Trace a real preemption: victim selection,
nominatedNodeName, graceful termination. - Read the
PreemptedandFailedSchedulingevents well enough to explain any outcome. - Know where priority stops helping — PodDisruptionBudgets, kubelet node-pressure eviction, and priority inflation.
Prerequisites
- A Kubernetes cluster on 1.24 or newer, where pod priority and preemption are stable (
scheduling.k8s.io/v1). Everything here also applies to 1.28–1.33; only event message wording has shifted slightly across releases. kubectlwith permission to create cluster-scopedPriorityClassobjects, plusget,list, anddeleteon pods and events in a test namespace.- A cluster you can safely fill up. The demonstration deliberately makes pods unschedulable and then evicts them, so use a scratch namespace, not production.
- Pods that actually declare
resources.requests. Priority only matters when the scheduler runs out of allocatable capacity, and allocatable capacity is measured in requests — see CPU and memory requests versus limits if yours are unset. - If you use a cluster autoscaler, note that it will react to the pending pod too. Scale it down to zero, or accept that a new node may appear before preemption happens.
How it works
A pod’s priority is an int32 in spec.priority. You almost never set it directly: you set spec.priorityClassName to the name of a PriorityClass, and the Priority admission controller — enabled by default — looks up that class and writes its value into spec.priority at admission time. Both fields are then immutable for the life of the pod. If a pod names a class that does not exist, the API server rejects the pod outright rather than defaulting it, which is why a deleted PriorityClass breaks every workload that referenced it.
Priority does two things. In the scheduling queue, higher-priority pending pods are attempted before lower-priority ones — that alone is often enough. Then, if no node can host the pod, the scheduler runs preemption: for each candidate node it asks “if I removed some lower-priority pods here, would this pod fit?” Among nodes where the answer is yes, it prefers the node whose victim set does the least damage. The ordering is roughly: fewest PodDisruptionBudget violations, then the lowest highest priority among victims, then the smallest total priority, then the fewest pods. In practice: low-priority pods go first, and the scheduler avoids budgets when it can.
PodDisruptionBudgets are respected on a best-effort basis only. The scheduler prefers victim sets that break no budget, but if every viable set breaks one, it still preempts. A PDB does not make a pod un-preemptible — see PodDisruptionBudgets for what a budget does and does not stop.
Victims are deleted, not killed. Each gets its terminationGracePeriodSeconds, so the pending pod does not become schedulable the instant preemption is decided. To bridge that gap, the scheduler writes status.nominatedNodeName on the pending pod, which reserves the intent and lets other scheduling decisions account for it. It is a hint, not a binding — the pod can still end up elsewhere if capacity frees up sooner.
Finally, value has a ceiling. User-defined classes cap at 1000000000 (one billion). The two built-in classes sit above it: system-cluster-critical at 2000000000 and system-node-critical at 2000001000, reserved for control-plane and node components so nothing you create can preempt them.
Step-by-step
1. Look at what already exists. Every cluster ships the two system classes, and often one from an add-on:
kubectl get priorityclass
NAME VALUE GLOBAL-DEFAULT PREEMPTIONPOLICY AGE
system-cluster-critical 2000000000 false PreemptLowerPriority 84d
system-node-critical 2000001000 false PreemptLowerPriority 84d
GLOBAL-DEFAULT false on both is the important part: pods with no priorityClassName get priority 0 unless you create a default yourself.
2. Create a preempting class for critical workloads. Leave room between tiers so you can insert one later without recreating everything:
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: critical-tier
value: 1000000
globalDefault: false
description: "Customer-facing request path. Preempts batch and background work."
kubectl apply -f critical-tier.yaml
priorityclass.scheduling.k8s.io/critical-tier created
The description is not decoration — it is the only place the rule for using a tier is recorded next to the object, and kubectl describe priorityclass prints it.
3. Create a non-preempting class. Sometimes you want a workload to jump the queue without ever evicting anything — a nightly report that should start before other batch jobs but must not disturb them:
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: batch-tier
value: 10000
globalDefault: false
preemptionPolicy: Never
description: "Queue priority over default work, but never evicts other pods."
kubectl apply -f batch-tier.yaml
kubectl get priorityclass batch-tier -o jsonpath='{.preemptionPolicy}{"\n"}'
Never
preemptionPolicy defaults to PreemptLowerPriority and is only meaningful on the incoming pod. Never means “this pod waits” — it does not protect pods that carry the class from being preempted by something higher.
4. Attach a class to a workload. priorityClassName goes in the pod template, next to the container spec, not in the Deployment’s own metadata:
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-frontend
spec:
replicas: 3
selector:
matchLabels:
app: api-frontend
template:
metadata:
labels:
app: api-frontend
spec:
priorityClassName: critical-tier
terminationGracePeriodSeconds: 30
containers:
- name: api
image: registry.example.com/api:1.4.2
resources:
requests:
cpu: 500m
memory: 512Mi
5. Confirm the admission controller resolved the number. This is the check most people skip, and it is the one that catches a typo in the class name — or an old pod created before the class changed:
kubectl get pods -l app=api-frontend \
-o custom-columns=NAME:.metadata.name,CLASS:.spec.priorityClassName,PRIORITY:.spec.priority
NAME CLASS PRIORITY
api-frontend-7d9c4f8b5-2xkqp critical-tier 1000000
api-frontend-7d9c4f8b5-8mzvr critical-tier 1000000
api-frontend-7d9c4f8b5-q4wnd critical-tier 1000000
6. Cause a preemption on purpose. Fill the namespace with default-priority pods that request most of the node, then submit a critical-tier pod that cannot fit. Watch the pending pod:
kubectl get pod api-frontend-7d9c4f8b5-2xkqp \
-o jsonpath='{.status.nominatedNodeName}{"\n"}'
ip-10-0-1-42.ec2.internal
A non-empty nominatedNodeName on a Pending pod is the definitive signal that preemption has been decided and is in progress.
7. Read the events on both sides. The victim carries the Preempted event; the preemptor carries FailedScheduling until it binds:
kubectl get events --field-selector reason=Preempted --sort-by=.lastTimestamp
LAST SEEN TYPE REASON OBJECT MESSAGE
18s Normal Preempted pod/batch-fill-6b8d9-jt4kx Preempted by pod 4f2a1c9e-... on node ip-10-0-1-42.ec2.internal
8. Fence the class off with quota. A PriorityClass is cluster-scoped, so any namespace can name it. ResourceQuota with a PriorityClass scope is the only mechanism that limits who actually gets to use it:
apiVersion: v1
kind: ResourceQuota
metadata:
name: critical-tier-cap
namespace: payments
spec:
hard:
pods: "20"
scopeSelector:
matchExpressions:
- operator: In
scopeName: PriorityClass
values: ["critical-tier"]
kubectl apply -f critical-tier-cap.yaml
kubectl describe quota critical-tier-cap -n payments
Name: critical-tier-cap
Namespace: payments
Scopes: PriorityClass
Resource Used Hard
-------- ---- ----
pods 3 20
Validate it works
Every class you expect is present, with the values you expect.
kubectl get priorityclass -o custom-columns=NAME:.metadata.name,VALUE:.value,DEFAULT:.globalDefault,POLICY:.preemptionPolicy
NAME VALUE DEFAULT POLICY
batch-tier 10000 <none> Never
critical-tier 1000000 <none> PreemptLowerPriority
system-cluster-critical 2000000000 <none> PreemptLowerPriority
system-node-critical 2000001000 <none> PreemptLowerPriority
The pending critical pod actually became Running, and the low-priority pods went away.
kubectl get pods -o wide --sort-by=.spec.priority
Confirm the critical-tier pod holds a node and the batch-fill pods are gone or Pending.
The preemption is recorded end to end. Read the pending pod’s own events, which show the scheduling failure and then the successful bind:
kubectl describe pod api-frontend-7d9c4f8b5-2xkqp | tail -n 12
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 62s default-scheduler 0/4 nodes are available: 4 Insufficient cpu.
Normal Scheduled 31s default-scheduler Successfully assigned payments/api-frontend-7d9c4f8b5-2xkqp to ip-10-0-1-42.ec2.internal
Troubleshooting
FailedSchedulingsays no preemption victims were found. The message reads roughly0/4 nodes are available: 4 Insufficient cpu. preemption: 0/4 nodes are available: 4 No preemption victims found for incoming pod.Two causes: every pod on every candidate node is at equal or higher priority, or removing all the lower-priority pods on a node still would not free enough capacity for this one. Check what is actually running withkubectl get pods -A --sort-by=.spec.priority -o wide. If the pending pod requests more than a whole node can offer, preemption can never help — that is a capacity or request-sizing problem.- The pod has
nominatedNodeNamebut staysPendingfor minutes. Victims are still terminating. A longterminationGracePeriodSeconds, apreStophook that sleeps, or a stuck finalizer all extend the wait, and the scheduler will not bind until the resources are genuinely released. Confirm withkubectl get pod <victim> -o jsonpath='{.metadata.deletionTimestamp}'— if it is set, the delete is in flight. Shorten grace periods on preemptible batch work; do not shorten them on anything that needs to flush state. - The API server rejects the
PriorityClass. Avalueabove the user ceiling fails withvalue: Invalid value: 2000000000: maximum allowed value of a user defined priority is 1000000000. Separately,valueis immutable after creation — editing it fails with amay not be changed in an updateerror. To retier, create a new class with the new value, roll workloads onto it, then delete the old class once no pod references it. - The victims come straight back and get preempted again. Preempting a pod owned by a Deployment or Job does not remove the workload — the controller recreates the pod, it cannot be scheduled, and you get a churn loop of create, fail, delete. The event log fills with
PreemptedandFailedSchedulingin alternation. The fix is capacity or a smaller replica count for the low-priority workload, not more priority. Scale the batch workload down, or gate it behind a queue that respects available capacity. - A new
globalDefault: trueclass did not change existing pods. The default is applied at admission only. Pods already running keep the priority they were admitted with (usually0), and they will keep it until they are recreated. Roll the workloads to pick it up. Also note only one class may haveglobalDefault: true; if two do, the smaller value wins and the situation is ambiguous enough that you should fix it immediately. - Priority did not stop a pod from being killed under memory pressure. That is kubelet node-pressure eviction, not scheduler preemption. Kubelet ranks candidates first by whether usage exceeds requests, then by pod priority, then by usage relative to requests — so a high-priority pod exceeding its memory request can still be evicted ahead of a low-priority pod living within its request. Correct requests are the defence there, not priority.
When this is the wrong approach
Priority decides who wins a fight for capacity. It does not create capacity, and it is not a guarantee of anything.
- It is not a substitute for right-sized requests. A pod whose requests exceed any single node’s allocatable capacity stays
Pendingat any priority. Fix the requests, or the node shape. - It is not a substitute for capacity planning or autoscaling. If preemption fires routinely, the cluster is chronically full and you are paying for it in evicted work and restart churn. Add nodes, or reduce the low-priority footprint.
- It does not protect against disruption generally. Node drains, upgrades, spot reclamation, and node-pressure eviction each follow their own rules. High priority influences some of them and is ignored by others.
- It is the wrong tool for tenant fairness. If the goal is “team A cannot starve team B”, use
ResourceQuotaand namespace limits. Priority is a strict ordering, and strict orderings let the top tier consume everything. - Priority inflation defeats it entirely. The moment every team sets
critical-tier, all pods are equal again, no preemption is possible, and you have added operational complexity for nothing. Keep the tiers few — a default, one above it, one below it is usually enough — write the rule for each into itsdescription, and enforce it with quota scopes. If pods are simply stuckPendingwith no preemption in sight, start from why a pod stays Pending instead.
The authoritative reference is the Kubernetes pod priority and preemption documentation, which specifies victim selection and the interaction with PodDisruptionBudgets exactly, alongside the broader scheduling and eviction concepts.
If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.