Priority Classes in Kubernetes: Scheduling


What Are Priority Classes?
A PriorityClass in Kubernetes is a non-namespaced object that assigns an integer priority value to pods. The higher the integer, the higher the scheduling priority.
They are used in:
Pod scheduling: Determines which pods get scheduled first when resources are limited.
Pod preemption: Allows high-priority pods to evict lower-priority pods if necessary.
Why Use Priority Classes?
Without priority classes, Kubernetes uses a default scheduling behavior that treats all pods equally. In real-world environments, this doesn’t work well—your logging daemon or critical API service should not be evicted in favor of a batch analytics job.
Priority Classes help by:
Protecting critical workloads from being preempted.
Allowing cluster resources to be allocated based on workload importance.
Ensuring predictable behavior under resource pressure.
How to Create a Priority Class
Here’s a simple example of a PriorityClass
definition:
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: high-priority
value: 100000
globalDefault: false
description: "This priority class is for critical production workloads."
# leaderElect (optional and advanced concept)
value
: Integer indicating the priority level (higher = more important).globalDefault
: If true, pods without a specified priority class will use this.description
: Useful for documentation.
Using Priority Class in a Pod
Once the class is defined, reference it in your pod spec:
apiVersion: v1
kind: Pod
metadata:
name: my-critical-app
spec:
priorityClassName: high-priority
containers:
- name: app
image: nginx
Kubernetes will now schedule this pod with higher importance.
Pod Preemption: The Fine Print
If a high-priority pod cannot be scheduled due to lack of resources, Kubernetes can preempt (i.e., evict) lower-priority pods to make room. Some caveats:
Only pods without
PodDisruptionBudgets
are considered for preemption.Preemption favors evicting the lowest-priority pods first.
You can disable preemption at the pod level using:
preemptionPolicy: Never
# preemptionPolicy: PreemptLowerPriority # will evict lower priority pods
Example: Multiple Priority Classes
# Low priority for batch jobs
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: low-priority
value: 1000
globalDefault: false
---
# Medium priority for general services
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: medium-priority
value: 50000
globalDefault: true
---
# High priority for critical services
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: high-priority
value: 100000
How to View Priority Classes
You can list all defined PriorityClasses using:
kubectl get priorityclass
To describe a specific one:
kubectl describe priorityclass high-priority
Further Reading:
Subscribe to my newsletter
Read articles from Rohit directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Rohit
Rohit
I'm a results-driven professional skilled in both DevOps and Web Development. Here's a snapshot of what I bring to the table: 💻 DevOps Expertise: AWS Certified Solutions Architect Associate: Proficient in deploying and managing applications in the cloud. Automation Enthusiast: Leveraging Python for task automation, enhancing development workflows. 🔧 Tools & Technologies: Ansible, Terraform, Docker, Prometheus, Kubernetes, Linux, Git, Github Actions, EC2, S3, VPC, R53 and other AWS services. 🌐 Web Development: Proficient in HTML, CSS, JavaScript, React, Redux-toolkit, Node.js, Express.js and Tailwind CSS. Specialized in building high-performance websites with Gatsby.js. Let's connect to discuss how my DevOps skills and frontend expertise can contribute to your projects or team. Open to collaboration and always eager to learn! Aside from my work, I've also contributed to open-source projects, like adding a feature for Focalboard Mattermost.