PriorityClass Resources
What You'll Learn
You'll learn how to define and use PriorityClass objects to classify pods with different priority levels and control preemption behavior in your Kubernetes cluster.
Understanding PriorityClass
A PriorityClass is a cluster-level Kubernetes resource that assigns a numeric priority value to pods. When the scheduler can't find resources for a high-priority pod, it can evict (preempt) lower-priority pods to make room—like VIP passengers bumping economy travelers from an overbooked flight.
PriorityClasses work hand-in-hand with the Pod Priority concept you learned earlier. While pod priority is the mechanism, PriorityClass is the reusable configuration object that defines those priorities.
Core Components
A PriorityClass contains:
- value: An integer priority (higher = more important, typically 0-1000000000)
- globalDefault: Optional boolean; if true, this priority applies to pods without an explicit priorityClassName
- preemptionPolicy: Controls whether this priority class can preempt others (
PreemptLowerPriorityorNever) - description: Human-readable explanation of when to use this class
How It Works
You create PriorityClass objects once at the cluster level, then reference them by name in your pod specs using the priorityClassName field. The scheduler uses these values to make scheduling and preemption decisions when nodes are under resource pressure.
Higher priority pods get scheduled first. If no resources are available, the scheduler may evict lower-priority pods to accommodate them—but only if the PriorityClass allows preemption.
Key Takeaway: PriorityClass resources define reusable priority levels with numeric values and preemption policies, enabling you to classify pods by importance and control how the scheduler handles resource contention.