DevOpsCube Bytes

Share this post

Kubernetes Pod Priority & Preemption

bytes.devopscube.com

Kubernetes Pod Priority & Preemption

Important Pod Scheduling features

Bibin Wilson
Apr 26, 2022
2
Share this post

Kubernetes Pod Priority & Preemption

bytes.devopscube.com

Pod priority is a Kubernetes scheduling feature that allows Kubernetes to make scheduling decisions comparing other pods based on priority number.

To assign a pod a certain priority, you need a priority class.

You can set a priority for a Pod using the PriorityClass object (non-namespaced) with a Value.

The value determines the priority. It can be 1,000,000,000 (one billion) or lower. Larger the number, the higher the priority.

Also, there are two default high-priority classes set by Kubernetes

  1. system-node-critical: This class has a value of 2000001000. Pods like etcd, kube-apiserver, and Controller manager use this priority class.

  2. system-cluster-critical: This class has a value of 2000000000. Addon Pods like coredns, calico controller, metrics server, etc use this Priority class.

How Does Pod Priority Work?

Here is how pod priority work,

  1. If a pod is deployed with PriorityClassName, the priority admission controller gets the priority value using the PriorityClassName value.

  2. If there are many pods in the scheduling queue, the scheduler arranges the scheduling order based on priority. Meaning, the scheduler places the high priority pod ahead of low priority pods

  3. Now, if there are no nodes available with resources to accommodate a higher priority pod, the preemption logic kicks in.

  4. The scheduler preempts (evicts) low priority pod from a node where it can schedule the higher priority pod. The evicted pod gets a graceful default termination time of 30 seconds. If pods have terminationGracePeriodSeconds set for preStop container Lifecycle Hooks, it overrides the default 30 seconds.

  5. However, if for some reason, the scheduling requirements are not met, the scheduler goes ahead with scheduling the lower priority pods.

Note: This is an excerpt from an article published on devopscube.com. For a detailed example please visit → Pod PriorityClass Explained

Thanks for reading DevOpsCube Bytes! Subscribe for free to receive new posts and support my work.

Share this post

Kubernetes Pod Priority & Preemption

bytes.devopscube.com
Comments
TopNew

No posts

Ready for more?

© 2023 Bibin Wilson
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing