I have some burstable pods running in cluster, which I do not want to be killed in case of memory/cpu pressure.
Is there any way to increase it's priority or something, so that we do not have to change it's namespace (kube-system for making it critical) and it can be saved?
I have found some issues regarding adding priority to pods. But couldn't figure out the solution. There should be some way to set priority, or am I missing something big here ?
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 priorityglobalDefault
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.