Priorities in Pods in Kubernetes
Asked Answered
N

1

7

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 ?

Nassir answered 18/9, 2017 at 7:8 Comment(1)
I think you are right about the referenced issue; it is the way to go in the future. If you don't want to use kube-system (critical pod); then right now, the best option i can think of is to run in Guaranteed QoS.Brockie
C
6

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.

Clough answered 12/2, 2018 at 4:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.