Skip to main content
RunBook Academy

KubernetesCX · Priority and PreemptionPriority and preemption

PriorityClass — workload priority in Kubernetes

Advanced⏱ ~17 minkubectl

What you'll learn

  • Define PriorityClass for production workloads
  • Apply the globalDefault flag
  • Reason about preemption policies
  • Apply the operational discipline of using PriorityClass for production workloads

Prerequisites

Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16

Not yet marked complete on this device.

PriorityClass defines the priority of a Pod in Kubernetes. This lesson walks the priority value, the preemption policy, system classes, the use cases, and the discipline.

The PriorityClass concept

flowchart LR
    A[PriorityClass] --> B["value: priority"]
    A --> C["globalDefault: applied to Pods without priority"]
    A --> D["preemptionPolicy: Never or PreemptLowerPriority"]
    E[Pod] -->|spec.priorityClassName| A
    A --> F["Scheduler: orders Pods by priority"]

A PriorityClass defines:

  • value. A 32-bit integer; higher = more important. Values above 1 billion are reserved for system classes.
  • globalDefault. If true, the class is the default for Pods without explicit priorityClassName.
  • preemptionPolicy. Whether Pods of this class can preempt lower-priority Pods.

The scheduler uses the priority to:

  • Order pending Pods. Higher priority Pods are scheduled first.
  • Decide preemption. When the cluster is full, higher priority Pods preempt lower priority Pods.

A PriorityClass example

apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: production-critical
value: 1000000
globalDefault: false
description: "Production-critical workloads (checkout, payment)"
preemptionPolicy: PreemptLowerPriority

This PriorityClass:

  • Value 1,000,000 (well below 1 billion).
  • Not the global default.
  • Preempts lower-priority Pods when the cluster is full.

The use cases

flowchart LR
    A[Production-critical] --> A1["Checkout, payment"]
    A1 --> A2["Value: 1000000"]
    A1 --> A3[PreemptLowerPriority]
    B[Production] --> B1["Catalog, accounts"]
    B1 --> B2["Value: 100000"]
    B1 --> B3[PreemptLowerPriority]
    C[Batch] --> C1["Analytics, reports"]
    C1 --> C2["Value: 10000"]
    C1 --> C3[Never]

The use cases:

  • Production-critical. Checkout, payment. Highest priority; preempts lower priority.
  • Production. Catalog, accounts. Medium priority; preempts lower priority.
  • Batch. Analytics, reports. Low priority; never preempts (no graceful eviction of production).

A workload’s PriorityClass matches its business importance.

The globalDefault flag

apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: default
value: 1000
globalDefault: true

The globalDefault: true flag makes the class the default. Pods without spec.priorityClassName are assigned this priority. Only one PriorityClass can be the global default.

In production, a sensible default is set so that Pods without explicit priority have a meaningful value. Without a global default, Pods have priority 0 (the lowest).

The preemption policy

preemptionPolicy: PreemptLowerPriority  # default
# or
preemptionPolicy: Never

The preemption policy:

  • PreemptLowerPriority (default). The Pod can preempt lower-priority Pods to make room.
  • Never. The Pod never preempts. It waits for resources to become available.

Use Never for batch workloads that should not disrupt production. Use PreemptLowerPriority for critical workloads that must run.

System classes

apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: system-cluster-critical
value: 2000000000
globalDefault: false
description: "Pods critical to the cluster"
---
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: system-node-critical
value: 3000000000
globalDefault: false
description: "Pods critical to the node"

System PriorityClasses are installed automatically in modern Kubernetes. They protect:

  • kube-proxy. Required for Service traffic.
  • CoreDNS. Required for cluster DNS.
  • CNI agents. Required for pod networking.

These are never preempted.

Quiz

Knowledge check · 4 questions

  1. Q1. What does a higher PriorityClass value give a Pod?

  2. Q2. A high PriorityClass protects a Pod from being evicted when its node runs short of memory.

  3. Q3. A nightly batch job is evicting production Pods; correct the priority ladder without waiting for the next window.

    At 02:10 the `payments-api` Deployment lost 4 of its 12 Pods. Events in `payments-prod` read `Preempted by analytics/spark-executor-77 on node worker-09`. `kubectl get priorityclass` lists `batch-analytics` at value 900000 and `production` at value 100000, and neither sets `preemptionPolicy`.

  4. Q4. Where does a Pod's numeric priority live once it has been admitted, and what happens to it if the PriorityClass it named is changed afterwards?

Passing score: 75%. Answers are checked in this browser.

The operational discipline

PriorityClass in production rests on five non-negotiable elements:

  • Define production priority classes. Critical, high, medium, low.
  • Set a globalDefault. Pods without explicit priority have a meaningful default.
  • Use system classes. Critical components use system-cluster-critical or system-node-critical.
  • Assign workloads deliberately. Production workloads get high priority; batch gets low.
  • Document the priority scheme. The runbook lists the classes and their use cases.

PriorityClass is the operational signal for what matters. The discipline is to assign priorities deliberately, based on business importance.