Sub topic 14
QoS and Priority Compared
This chapter assumes you know how requests and limits work, how a Pod gets its QoS class, and how a PriorityClass is assigned. Here we compare the two mechanisms and decide which one to tune for a given problem.
Two separate mechanisms
QoS class and priority are independent. Neither one is derived from the other.
- QoS class comes from the container requests and limits in the Pod spec. Kubernetes sets it automatically. It is stored in
status.qosClass. - Priority comes from the
priorityClassNameyou set. It is an integer stored inspec.priority.
A Pod can be Guaranteed with a low priority, or BestEffort with a very high priority. Setting one does not change the other.
Who uses which signal
Each component of the cluster looks at a different signal.
| Component | Decision | QoS class | Priority |
|---|---|---|---|
| kube-scheduler | Queue order | Not used | Used |
| kube-scheduler | Preemption victims | Not used | Used |
| kubelet | Node-pressure eviction order | Used with usage over requests | Used |
| Linux OOM killer | Which process dies | Used through `oom_score_adj` | Not used |
The scheduler ignores QoS. It orders the queue by priority and picks preemption victims from lower-priority Pods. The kernel OOM killer knows nothing about priority. It sees only the score the kubelet set from the QoS class and memory requests.
The kubelet is the one place where both matter. When it evicts Pods under node pressure, it ranks them in this order:
- Whether the Pod's usage of the starved resource is above its request.
- Pod priority.
- How far usage is above the request.
QoS class is not a direct sort key here. It matters indirectly. A Guaranteed Pod's usage cannot exceed its request, so it is ranked after Pods that are over their requests.
A worked contrast
Consider two Pods on a node that runs out of memory.
- Pod A is Guaranteed with priority 0. It uses exactly its request.
- Pod B is BestEffort with priority 1000000. It has no request, so any usage is over its request.
The kubelet ranks Pod B ahead of Pod A for eviction, because B is over its request and A is not. Priority only breaks ties among Pods in the same group. But if the kernel OOM killer fires before the kubelet reacts, B is killed first as well, because BestEffort gets the highest oom_score_adj.
Now put the same two Pods in a cluster with no free CPU. Pod B can preempt Pod A at scheduling time, since B has the higher priority. A's Guaranteed class does not protect it from preemption.
Choosing what to tune
| Problem | Tune | Why |
|---|---|---|
| Critical Pod stays Pending while the cluster is full | Priority | The scheduler can then preempt lower-priority Pods. |
| Pod is OOM killed while other Pods survive | Memory request and limit, so QoS is Guaranteed or Burstable | `oom_score_adj` comes from QoS. |
| Pod is evicted under node pressure | Requests, so usage stays below them, and priority | Both feed the kubelet ranking. |
| Batch jobs should not evict running work | `preemptionPolicy: Never` | The Pod queues ahead but evicts nothing. |
Exercise
A BestEffort Pod with priority 1000000 and a Guaranteed Pod with priority 0 run on the same node, and the node runs low on memory. Which does the kubelet evict first, and why? Would it protect the Guaranteed Pod from being preempted by a new high-priority Pod?
Show answer
The kubelet evicts the BestEffort Pod first. It has no memory request, so its usage is over its request, and the kubelet ranks Pods over their requests before Pods within them. Priority only orders Pods within the same group. The Guaranteed class does not protect against preemption. The scheduler selects victims by priority alone, so a new Pod with higher priority than 0 can preempt the Guaranteed Pod.