Skip to content

2.10 Priority Classes

  • Kubernetes allows running workloads (pods) with different priorities to ensure that critical applications always get the resources they need.
  • For example, Kubernetes control plane components must always run, even if lower-priority applications need to be terminated.

πŸ”Ή What Are Priority Classes?

Priority Classes define the scheduling importance of workloads in Kubernetes.
They determine which pods get scheduled first and which can be preempted (evicted) when resources are scarce.

  • Higher priority workloads are scheduled before lower priority ones.
  • If necessary, lower-priority pods may be terminated to make room for higher-priority pods.
  • Priority Classes are non-namespaced objects, meaning they are available cluster-wide and can be applied to pods in any namespace.

πŸ”Ή Priority Range

priority

  • Priority values are represented as integers.
  • The general range for user workloads is between -2,000,000,000 and +1,000,000,000.
  • Higher numbers represent higher priority.
  • Kubernetes system-critical components (like control plane pods) use values up to 2,000,000,000, ensuring they are never preempted by regular workloads.

🧾 PriorityClass Definition (Click to Expand)
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: high-priority
value: 1000000000
description: "Priority class for mission-critical pods"
🧩 Pod Using PriorityClass (Click to Expand)
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
    - name: nginx
      image: nginx
      ports:
        - containerPort: 8080
  priorityClassName: high-priority
βš™οΈ Default PriorityClass (Click to Expand)
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: default-priority
value: 1000
globalDefault: true
description: "Default priority for pods without explicit priority class"
🚫 Non-Preempting PriorityClass (Click to Expand)
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: non-preempting
value: 600000000
preemptionPolicy: Never
description: "Non-preempting priority class that waits for resources"

πŸ”Ή Default PriorityClass vs Non-Preempting PriorityClass

Feature Default PriorityClass Non-Preempting PriorityClass
Purpose Defines the default priority for pods that don’t specify a priorityClassName. Prevents pods from evicting existing lower-priority pods.
Key Field globalDefault: true preemptionPolicy: Never
Effect on Pods All pods without a defined priority class will automatically use this class. Pods will wait in the scheduling queue until resources are available instead of preempting others.
Preemption Behavior Can preempt lower-priority pods (default Kubernetes behavior). Will not preempt any running pods, even if higher in priority.
Number Allowed Only one Default PriorityClass is allowed per cluster. You can create multiple Non-Preempting PriorityClasses.
Use Case When you want to assign a baseline priority to all workloads. When you want critical pods to have priority in scheduling but avoid disrupting running workloads.