// Module included in the following assemblies:
//
// * nodes/nodes-pods-priority.adoc

[id="nodes-pods-priority-examples_{context}"]
= Pod priority example scenarios

Pod priority and preemption assigns a priority to pods for scheduling. The scheduler will preempt (evict) lower-priority pods to schedule higher-priority pods.

Typical preemption scenario::
*Pod P* is a pending pod. 

. The scheduler locates *Node N*, where the removal of one or more pods enables *Pod P* to be scheduled on that node. 

. The scheduler deletes the lower-priority pods from the *Node N* and schedules *Pod P* on the node. 

. The `nominatedNodeName` field of *Pod P* is set to the name of *Node N*.

[NOTE]
====
*Pod P* is not necessarily scheduled to the nominated node.
==== 

Preemption and termination periods::
The preempted pod has a long termination period. 

. The scheduler preempts a lower-priority pod on *Node N*.

. The scheduler waits for the pod to gracefully terminate. 

. For other scheduling reasons, *Node M* becomes available. 

. The scheduler can then schedule *Pod P* on *Node M*. 

////
Under consideration for future release
Pod priority and cross-node preemption::
*Pod P* is being considered for *Node N*.

. *Pod Q* is running on another node in the same zone as *Node N*.

. *Pod P* has zone-wide anti-affinity with *Pod Q*, meaning *Pod P* cannot be scheduled in the same zone as *Pod Q*.
+
There are no other cases of anti-affinity between *Pod P* and other pods in the zone.

. To schedule *Pod P* on *Node N*, the scheduler must preempt *Pod Q* to remove the pod anti-affinity violation, allowing the scheduler to schedule *Pod P* on *Node N*.

The scheduler can preempt *Pod Q*, but scheduler does not perform cross-node preemption. So, Pod P will be deemed unschedulable on Node N. 
////

