Assigning Priority to Pods
What you'll learn: How to reference PriorityClass resources in your pod specifications to control which pods get scheduled first during resource contention.
Connecting Priority to Your Pods
You've already created PriorityClass resources to define different priority tiers in your cluster. Now it's time to actually use them. Assigning priority to a pod is straightforward: you reference a PriorityClass by name in your pod specification.
Think of it like assigning a boarding group to an airline ticket. The PriorityClass is the boarding group definition (Group 1, Group 2, etc.), and assigning it to your pod is like printing that group number on the ticket itself.
How to Assign Priority
In your pod spec, use the priorityClassName field:
apiVersion: v1
kind: Pod
metadata:
name: high-priority-app
spec:
priorityClassName: high-priority # References an existing PriorityClass
containers:
- name: app
image: nginx
When Kubernetes schedules this pod, it checks the referenced PriorityClass and uses its priority value. If resources are tight, higher-priority pods get scheduled before lower-priority ones. In extreme cases, the scheduler may even preempt (evict) lower-priority pods to make room.
What Happens Without a Priority Assignment
If you don't specify a priorityClassName, the pod gets the cluster's default priority (typically 0) or inherits from a default PriorityClass if one is configured. All pods without explicit priorities are treated equally.
Best Practice
Always assign meaningful PriorityClasses to workloads that matter most—like critical system components or revenue-generating services. Reserve the highest priorities for truly essential pods.
Key Takeaway: Assign priority to pods by setting priorityClassName in the pod spec to an existing PriorityClass name, ensuring critical workloads get scheduled first during resource contention.