Pod priority feature is not available prior to Kubernetes v1.7
From v1.8+
, you can add pod's priority in PodSpec. You need to create PriorityClass object with priority value and use that PriorityClass name in Pod.
But upto v1.9
, PriorityClass is still in alpha phase.
apiVersion: scheduling.k8s.io/v1alpha1
kind: PriorityClass
metadata:
name: high-priority
value: 1000000
globalDefault: false
Here,
value
indicates priority. The higher the value, the higher the priority
globalDefault
indicates that the value of this PriorityClass should be used for Pods without a PriorityClassName. Only one PriorityClass with globalDefault set to true can exist in the system.
Now, lets create a Pod with this Priority
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
containers:
- name: nginx
image: nginx
priorityClassName: high-priority
Preemption
When Pod is created, if no Node is found that satisfies all the specified requirements of that Pod, using preemption logic one or more lower priority Pods get deleted from the Node. After the Pods are gone, Pod with higher priority is scheduled on the Node.
See details about pod priority.