Requests decide whether a Pod fits. Priority decides who gives way when it does not.
A PriorityClass
kubectl create priorityclass high --value=1000 --description="urgent work"
kubectl get priorityclassNAME VALUE GLOBAL-DEFAULT AGE
high 1000 false 5s
system-cluster-critical 2000000000 false 12d
system-node-critical 2000001000 false 12dA PriorityClass is cluster-scoped and holds a number. The two system classes exist on every cluster; control-plane Pods use them so nothing you create can push them out.
Using it
spec:
priorityClassName: high
containers:
- name: job
image: stackmonsters/monster-market-workerAt admission the API server looks the class up and writes spec.priority: 1000 into the Pod. Pods without a class get 0, unless one class is marked globalDefault. A name that does not exist is an error: no PriorityClass with name … was found.
Preemption
When a Pod cannot be scheduled and its priority is higher than some Pods already running, the scheduler looks for a node where evicting lower-priority Pods would free enough room. It picks the node where the fewest have to go, deletes them, and places the new Pod there once they are gone.
The victims get an event:
Normal Preempted Preempted by peaks/urgent on node peaks-node-2If a controller owns them, it recreates them, and they queue behind the urgent Pod. A bare Pod is simply gone.
Reading it
kubectl describe pod urgent | grep -i priority
kubectl get events --field-selector reason=PreemptedPriority: 1000
Priority Class Name: high