<p>I have some burstable pods running in cluster, which I do not want to be killed in case of memory/cpu pressure.</p>

<p>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?</p>

<p>I have found some <a href="https://github.com/kubernetes/kubernetes/issues/47604" rel="nofollow noreferrer">issues</a> 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 ?</p>

<p>Pod priority feature is not available prior to Kubernetes <code>v1.7</code></p>

<p>From <code>v1.8+</code>, you can add pod's priority in PodSpec. You need to create PriorityClass object with priority value and use that PriorityClass name in Pod.</p>

<p>But upto <code>v1.9</code>, PriorityClass is still in alpha phase. </p>

<pre><code>apiVersion: scheduling.k8s.io/v1alpha1
kind: PriorityClass
metadata:
  name: high-priority
value: 1000000
globalDefault: false
</code></pre>

<p>Here,</p>

<ul>
<li><code>value</code> indicates priority. The higher the value, the higher the priority</li>
<li><code>globalDefault</code> 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.</li>
</ul>

<p>Now, lets create a Pod with this Priority</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
  priorityClassName: high-priority
</code></pre>

<p><strong>Preemption</strong></p>

<p>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.</p>

<p>See details about <a href="https://v1-8.docs.kubernetes.io/docs/concepts/configuration/pod-priority-preemption/" rel="noreferrer">pod priority</a>.</p>
