Sub topic 9
Non-preempting priority classes
This chapter assumes you know how a PriorityClass assigns an integer priority to a Pod, and that the scheduler uses priority to order its queue and to preempt lower-priority Pods. Here you will see how to keep the queue ordering and drop the eviction.
The problem with preemption
A normal PriorityClass has preemptionPolicy: PreemptLowerPriority. When a high-priority Pod cannot be placed, the scheduler may evict lower-priority Pods to make room. That is right for latency-sensitive services. It is costly for work that is important but can wait, such as a batch job that has already run for hours. Evicting those Pods throws away their progress.
What `preemptionPolicy: Never` does
Setting preemptionPolicy: Never on a PriorityClass changes one behavior only. Pods in that class still sort ahead of lower-priority Pods in the scheduling queue. But if no node has room, the scheduler does not evict running Pods. The Pod stays Pending until resources free up.
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: high-priority-nonpreempting
value: 1000000
preemptionPolicy: Never
description: "Queued ahead of lower-priority Pods but never evicts running Pods."A Pod opts in the same way as with any PriorityClass, through priorityClassName.
apiVersion: v1
kind: Pod
metadata:
name: batch-analysis
spec:
priorityClassName: high-priority-nonpreempting
containers:
- name: app
image: nginx:1.27
resources:
requests:
cpu: "1"
memory: 512MiWhat changes and what does not
| Behavior | PreemptLowerPriority | Never |
|---|---|---|
| Queue position | Ahead of lower priority | Ahead of lower priority |
| Evicts running Pods | Yes, when needed | No |
| Can be preempted by others | Yes | Yes |
| Wait when cluster is full | Short | Possibly long |
The third row is easy to miss. preemptionPolicy: Never governs what the Pod does to others. It does not shield the Pod. A running non-preempting Pod can still be preempted by a higher-priority Pod whose policy allows preemption.
When to use it
- Batch or data-processing jobs that matter more than other batch work but must not kill running work.
- Pods that can tolerate delay and where wasted computation is expensive.
- Teams sharing a cluster where one team should get the next free capacity without disrupting others.
Avoid it for services that must start quickly. Such a Pod can wait indefinitely on a full cluster.
Checking behavior
A non-preempting Pod that cannot fit shows a FailedScheduling event. You will see no Preempted events caused by it.
kubectl describe pod batch-analysis | grep -iE 'priority|preemption|Events'
kubectl get events --field-selector reason=PreemptedCommon mistakes
- Expecting a non-preempting Pod to schedule quickly. Higher priority only moves it forward in the queue.
- Assuming it is protected from eviction. Protection comes from a higher priority or from the QoS class, not from this field.
- Setting a very high value without limits. See the later chapter on restricting priorities with ResourceQuota.
Exercise
A team's nightly report job uses a PriorityClass with value 500000 and preemptionPolicy: Never. The cluster is full of Pods with priority 0. What happens to the job's Pod, and can a Pod with priority 900000 and the default policy affect it once it is running?
Show answer
The job's Pod is placed ahead of priority-0 Pods in the queue but evicts none of them, so it stays Pending until capacity frees up. Once it is running, a Pod with priority 900000 and PreemptLowerPriority can preempt it, because Never only stops the job's Pod from preempting others.