Scheduling and nodesLesson 7 of 10
- Requests, limits and quotas, not reconciled
- QoS classes and node-pressure eviction, not reconciled
- cgroups, memory pressure and the OOM killer, not reconciled
- How the scheduler places a pod, not reconciled
- Affinity, taints and tolerations, not reconciled
- Topology spread constraints, not reconciled
- Priority and preemption, not reconciled
- Nodes and the kubelet, not reconciled
- Disruptions and PodDisruptionBudgets, not reconciled
- Cluster autoscaling, not reconciled
Priority and preemption
A PriorityClass gives pods an integer rank. The scheduler tries higher-ranked pods first and, when nothing fits, evicts lower-ranked pods to make room, honouring PodDisruptionBudgets only when it can.
Shows the lesson one block at a time. Arrow keys step, number keys jump to a scene, and Escape returns to the page where you were.
Requests and limits decide whether a pod fits on a node. They say nothing about which pod matters more when the cluster is full. Priority is that missing ranking: an integer on every pod that decides the order the scheduler tries pods in and, when nothing fits, which running pods it may remove to make room.
Reconcile, in 7 scenes
PriorityClass
PriorityClassA cluster-scoped object that maps a name to an integer priority. Pods refer to it by name inspec.priorityClassName.
A PriorityClass has one required field, value. Higher means more important. User-defined classes can use any 32-bit integer up to one billion, so the range is -2147483648 to 1000000000; values above that are reserved for the built-in system classes, and user class names cannot start with system-. Two optional fields complete it: description, free text that tells teams when to use the class, and globalDefault.
globalDefault: true makes the class’s value apply to pods that name no class. Only one class can carry it. Without a global default, a pod with no priorityClassName gets priority 0. That default matters more than it looks: if you introduce a low class for batch work and leave everything else unclassed, the batch work at 1000 outranks every unclassed service at 0.
The class name is resolved once. When a pod is created, the Priority admission controller looks up the class and writes its integer into spec.priority; if the class does not exist, the pod is rejected. Everything downstream, the scheduler and the kubelet included, reads the integer, not the name. That has three consequences:
- Adding a globalDefault class does not change pods that already exist.
- Deleting a class leaves existing pods untouched, but pods created afterwards that name it are rejected, which stalls every Deployment that uses it at its next rollout.
- The API server rejects a change to an existing class’s
value. To re-rank, create another class with the value you want and roll workloads onto it.
Keep the scheme small. Three or four tiers cover most clusters: the built-in classes for system add-ons, a class for user-facing services, a default for ordinary work and a low class for preemptible batch jobs. Leave wide gaps between values, such as 1000, 10000 and 100000, so a tier can be inserted later without renumbering, since values cannot be edited. Choose the globalDefault deliberately: a low default keeps every unclassified pod preemptible, while a mid-range default means only work that explicitly opts into a low class can become a victim.
Here are two classes, saved as classes.yaml:
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: batch-low
value: 1000
description: "Batch work that can wait or be preempted."
---
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: web-critical
value: 100000
description: "User-facing services."
Built-in classes
Every cluster ships two classes: system-cluster-critical at 2000000000 and system-node-critical at 2000001000. They sit above any value you can create, so nothing you define can preempt them. system-node-critical is for pods that must run on every node for the node itself to work, such as kube-proxy and the static control-plane pods. system-cluster-critical is for add-ons the whole cluster depends on, such as CoreDNS and metrics-server.
Use them only for that. A workload placed in a system class can preempt anything else in the cluster, and its priority pushes it toward the back of the kubelet’s node-pressure eviction ranking. That is exactly what you want for kube-proxy and exactly what you do not want for an application that leaks memory.
Queue order
Pending pods wait in the scheduling queue, sorted by priority; pods of equal priority keep the order in which they entered the queue. The scheduler takes the head of the queue, runs one scheduling cycle for it, and moves on. Scheduling cycles run serially, one pod at a time; only the binding step that writes the decision may run concurrently. A higher-priority pod therefore does not run alongside a lower one; it simply goes first.
Going first is not the same as blocking others. If the head pod cannot be scheduled, it goes back to wait with a back-off and the scheduler continues with lower-priority pods that might fit. Priority decides the order of attempts, not exclusive access to capacity.
Each cycle filters nodes and scores the feasible ones. In large clusters the scheduler stops looking once it has found enough feasible nodes, set by percentageOfNodesToScore. The default is adaptive: 50% of nodes in a 100-node cluster, falling linearly to 10% at 5000 nodes, never below 5%, and clusters with fewer than 100 feasible nodes are always checked in full. The Kubernetes documentation gives no fixed throughput figure for the scheduler, because throughput depends on cluster size, enabled plugins and this setting.
ExplainerThe scheduling pipeline
The pending pod web, labelled app=web. The controls edit its YAML.
pod.yaml
Edits rerun the scheduler as you type.
Filters, in order
- NodeUnschedulable
- NodeName
- TaintToleration
- NodeAffinity
- NodePorts
- NodeResourcesFit
- VolumeBinding
- PodTopologySpread
- InterPodAffinity
Drag the pod onto a node, or onto the scheduler to let it choose. On a touch screen, tap the pod, then tap a node. From the keyboard, Space picks it up and the arrow keys choose.
A placed pod carries a required node affinity on kubernetes.io/hostname, not spec.nodeName, so the scheduler still runs every filter and can refuse it.
kx-control-plane
control plane, no zone labeltaint node-role.kubernetes.io/control-plane:NoScheduleno app=web podsPlaced hereCPU3050m free of 4000m
Memory7902Mi free of 8192Mi
TaintToleration: node(s) had untolerated taint(s)
kx-worker
zone zone-a, disktype=ssd2 app=web podsPlaced hereCPU2800m free of 4000m
Memory6918Mi free of 8192Mi
Passed all 9 filters
kx-worker2
zone zone-b, disktype=ssdtaint dedicated=batch:NoScheduleno app=web podsPlaced hereCPU1400m free of 4000m
Memory4046Mi free of 8192Mi
TaintToleration: node(s) had untolerated taint(s)
kx-worker3
zone zone-b, disktype=hdd1 app=web podPlaced hereCPU1400m free of 2000m
Memory3534Mi free of 4096Mi
Passed all 9 filters
$
Each placement writes pods/<name>.yaml and runs kubectl apply on it; the command and the scheduler's event show here.
Nothing placed yet.
Scoring Each plugin scores 0 to 100, times its weight; the highest total wins.
| Plugin | kx-worker | kx-worker3 |
|---|---|---|
| Taint | 300100 × 3 | 300100 × 3 |
| Node | 00 × 2 | 00 × 2 |
| Node | 6666 × 1 | 5757 × 1 |
| Pod | 00 × 2 | 00 × 2 |
| Inter | 00 × 2 | 00 × 2 |
| Node | 7373 × 1 | 7070 × 1 |
| Image | 00 × 1 | 00 × 1 |
| Total of 1200 | 439 | 427 |
Event from default-scheduler
Normal Scheduled
Successfully assigned default/web to kx-worker
Stage 6 of 6
Bound to kx-worker: 2 nodes passed the filters and it scored highest, 439 of 1200.
Bound to kx-worker: 2 nodes passed the filters and it scored highest, 439 of 1200.
Preemption
When the filter phase leaves no feasible node, the scheduler’s PostFilter step runs preemption for the pending pod. Call that pod P. Nodes that failed a filter no eviction can fix, such as an untolerated taint, a node affinity mismatch or a cordon, are skipped, and the event counts them under “Preemption is not helpful for scheduling”. For every other node the scheduler asks: if every pod with lower priority than P were removed from this node, would P fit? A node with no lower-priority pods at all is counted under “No preemption victims found for incoming pod”. A node where P still would not fit repeats its filter reason, such as Insufficient cpu. Neither kind is a candidate. On each candidate the scheduler removes every lower-priority pod in simulation, then puts pods back one by one, highest priority first, as long as P still fits. The pods it cannot put back are that node’s victims, so preemption removes only as much as P needs.
When several nodes qualify, the scheduler prefers the node whose victims have the lowest priority, unless removing them would violate a PodDisruptionBudget, in which case it may choose a node with higher-priority victims. It then deletes the victims and writes the node’s name to P’s status.nominatedNodeName.
The transcript fills the three workers with a batch Deployment at batch-low, each replica requesting 3 of the node’s 4 CPUs, then adds a checkout Deployment at web-critical that needs 2 CPUs. The manifests are batch.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: batch
spec:
replicas: 3
selector:
matchLabels:
app: batch
template:
metadata:
labels:
app: batch
spec:
priorityClassName: batch-low
terminationGracePeriodSeconds: 10
containers:
- name: worker
image: busybox:1.37
command: ["sh", "-c", "sleep 3600"]
resources:
requests:
cpu: "3"
memory: 256Mi
and checkout.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: checkout
spec:
replicas: 1
selector:
matchLabels:
app: checkout
template:
metadata:
labels:
app: checkout
spec:
priorityClassName: web-critical
containers:
- name: web
image: nginx:1.30
resources:
requests:
cpu: "2"
memory: 128Mi
kubectl apply -f classes.yaml
priorityclass.scheduling.k8s.io/batch-low created priorityclass.scheduling.k8s.io/web-critical created
kubectl get priorityclass
NAME VALUE GLOBAL-DEFAULT AGE PREEMPTIONPOLICY batch-low 1000 false 0s PreemptLowerPriority system-cluster-critical 2000000000 false 30s PreemptLowerPriority system-node-critical 2000001000 false 30s PreemptLowerPriority web-critical 100000 false 0s PreemptLowerPriority
kubectl apply -f batch.yaml
deployment.apps/batch created
kubectl rollout status deployment batch
Waiting for deployment "batch" rollout to finish: 0 of 3 updated replicas are available... deployment "batch" successfully rolled out
kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES batch-bbd475b6c-d6vmv 1/1 Running 0 3s 10.244.3.2 kx-worker3 <none> <none> batch-bbd475b6c-njhpq 1/1 Running 0 3s 10.244.2.2 kx-worker2 <none> <none> batch-bbd475b6c-vz6cr 1/1 Running 0 3s 10.244.1.3 kx-worker <none> <none>
kubectl apply -f checkout.yaml
deployment.apps/checkout created
sleep 2
kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES batch-bbd475b6c-d6vmv 1/1 Running 0 5s 10.244.3.2 kx-worker3 <none> <none> batch-bbd475b6c-lvj5d 0/1 Pending 0 2s <none> <none> <none> <none> batch-bbd475b6c-njhpq 1/1 Running 0 5s 10.244.2.2 kx-worker2 <none> <none> batch-bbd475b6c-vz6cr 1/1 Terminating 0 5s 10.244.1.3 kx-worker <none> <none> checkout-644d785958-w7tll 0/1 Pending 0 2s <none> <none> kx-worker <none>
sleep 15
kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES batch-bbd475b6c-d6vmv 1/1 Running 0 20s 10.244.3.2 kx-worker3 <none> <none> batch-bbd475b6c-lvj5d 0/1 Pending 0 17s <none> <none> <none> <none> batch-bbd475b6c-njhpq 1/1 Running 0 20s 10.244.2.2 kx-worker2 <none> <none> checkout-644d785958-w7tll 1/1 Running 0 17s 10.244.1.4 kx-worker <none> <none>
kubectl get events --field-selector reason=Preempted
LAST SEEN TYPE REASON OBJECT MESSAGE 17s Normal Preempted pod/batch-bbd475b6c-vz6cr Preempted by pod 33cf2550-5999-4c00-add4-fd8b68fbb978 on node kx-worker
kubectl get events --field-selector reason=FailedScheduling
LAST SEEN TYPE REASON OBJECT MESSAGE 1s Warning FailedScheduling pod/batch-bbd475b6c-lvj5d 0/4 nodes are available: 1 node(s) had untolerated taint(s), 3 Insufficient cpu. preemption: 0/4 nodes are available: 1 Preemption is not helpful for scheduling, 3 Insufficient cpu. 17s Warning FailedScheduling pod/checkout-644d785958-w7tll 0/4 nodes are available: 1 node(s) had untolerated taint(s), 3 Insufficient cpu.
Read the second listing closely. The victim on kx-worker is Terminating, checkout is Pending with kx-worker in the NOMINATED NODE column, and the ReplicaSet has already created a replacement batch pod. Fifteen seconds later checkout runs on the node it was nominated for, and the replacement batch pod stays Pending. Its own FailedScheduling event shows preemption failing for it. On kx the only pod on each worker with a priority below batch-low is kindnet, the network agent, which runs without a PriorityClass and requests 100m CPU. Removing it would still leave every worker short of 3 CPUs, so the preemption half of the event repeats Insufficient cpu.
The nomination is a reservation, not a binding. While victims shut down, the scheduler keeps P’s claim on the node in mind when it places other pods. If another node frees up first, P may land there instead, so nominatedNodeName and nodeName can differ. If an even higher-priority pod arrives and wants the same node, the scheduler gives it the node and clears P’s nomination, which lets P preempt elsewhere.
Victims
A preempted pod is deleted through the normal graceful path. It gets a DisruptionTarget condition with reason PreemptionByScheduler, an event with reason Preempted, and its full terminationGracePeriodSeconds, 30 seconds unless the pod says otherwise. That grace period is a gap: P cannot start until the victims are gone. Lowering the grace period of low-priority pods shortens it; the batch pods above use 10 seconds.
PodDisruptionBudgets are respected only where possible. The scheduler prefers victims whose budgets survive the removal, but if no such set exists, preemption still happens and the budget is violated. Preemption is a scheduler decision, not a call to the Eviction API, so a PDB never answers it with a refusal. The reverse is also true: a PDB never blocks scheduling. It limits voluntary evictions and nothing else, so a Pending pod is never Pending because of a budget.
Two more limits shape which pods get chosen:
- Preemption works one node at a time. If P could fit on a node only after removing a pod on a different node, for example a pod that P has zone-wide anti-affinity with, the scheduler does not do it and the node is not a candidate.
- Required inter-pod affinity is evaluated per topology domain: a node passes when any node in its domain runs a matching pod. If P has required affinity to lower-priority pods on a node, removing them would break the rule, so the scheduler will not preempt there. Point affinity only at pods of equal or higher priority.
The scheduler also ignores QoS class when choosing victims. A Guaranteed pod at priority 1000 is preempted before a BestEffort pod at priority 5000.
Two patterns show up in practice. In the first, victims are removed and the preemptor still does not run on that node. Usually a pod of even higher priority arrived during the victims’ grace period and took the space, which is the intended behaviour; the original pod loses its nomination and preempts elsewhere. In the second, every preemption leaves a Pending pod behind, because the victims’ controllers recreate them at once and they cannot preempt anything themselves. That backlog means the cluster is short of capacity rather than misconfigured, and Pending pods are exactly the signal a node autoscaler acts on.
preemptionPolicy: Never
Some work deserves to go first but not to destroy work already running: a report that should start before the batch backlog, a training job that can wait for the next free node. preemptionPolicy: Never on the PriorityClass gives exactly that. Pods of the class are sorted ahead of lower-priority pods in the queue, but when nothing fits they wait instead of preempting. The field defaults to PreemptLowerPriority, and non-preempting classes have been stable since Kubernetes 1.24.
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: reports-first
value: 50000
preemptionPolicy: Never
description: "Runs ahead of batch work but never evicts it."
---
apiVersion: v1
kind: Pod
metadata:
name: report
spec:
priorityClassName: reports-first
restartPolicy: Never
containers:
- name: report
image: busybox:1.37
command: ["sh", "-c", "sleep 600"]
resources:
requests:
cpu: "2"
memory: 128Mi
With the same three batch pods filling the workers:
kubectl apply -f classes.yaml
priorityclass.scheduling.k8s.io/batch-low created priorityclass.scheduling.k8s.io/web-critical created
kubectl apply -f batch.yaml
deployment.apps/batch created
kubectl rollout status deployment batch
Waiting for deployment "batch" rollout to finish: 0 of 3 updated replicas are available... deployment "batch" successfully rolled out
kubectl apply -f report.yaml
priorityclass.scheduling.k8s.io/reports-first created pod/report created
sleep 10
kubectl get pod report -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES report 0/1 Pending 0 10s <none> <none> <none> <none>
kubectl get events --field-selector involvedObject.name=report
LAST SEEN TYPE REASON OBJECT MESSAGE 10s Warning FailedScheduling pod/report 0/4 nodes are available: 1 node(s) had untolerated taint(s), 3 Insufficient cpu. preemption: not eligible due to preemptionPolicy=Never.
kubectl delete deployment batch
deployment.apps "batch" deleted from default namespace
sleep 15
kubectl get pod report -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES report 1/1 Running 0 25s 10.244.3.3 kx-worker3 <none> <none>
The event spells out why nothing was preempted, and the pod started the moment capacity freed up. Two details are easy to miss. A non-preempting pod is still subject to the scheduler’s back-off, so after failed attempts it is retried less often and lower-priority pods that fit can start before it. And it is not protected by its policy: a pod with a higher priority can still preempt it.
Similar names, different mechanisms
Three other features share vocabulary with pod priority and are often confused with it.
Node-pressure eviction. When a node runs short of memory, disk or PIDs, the kubelet evicts pods to protect the node. It ranks candidates first by whether their usage of the starved resource exceeds their requests, then by pod priority, then by usage relative to requests. Priority is one input, but a high-priority pod that exceeds its requests can be evicted before a low-priority pod that stays within them. This is the kubelet acting locally, and it ignores PodDisruptionBudgets.
QoS classes. Guaranteed, Burstable and BestEffort describe how requests and limits are set. They feed the kubelet’s eviction ranking and OOM scores. They play no part in scheduler preemption.
API Priority and Fairness. The API server classifies incoming requests with FlowSchemas and shares its concurrency between PriorityLevelConfigurations in flowcontrol.apiserver.k8s.io/v1. It decides whose API calls wait when the API server is busy. It has nothing to do with pods or nodes, and a pod’s PriorityClass does not affect it.
kubectl --context kind-kx get priorityclasskubectl --context kind-kx apply -f classes.yamlkubectl --context kind-kx apply -f batch.yamlkubectl --context kind-kx describe nodes kx-worker kx-worker2 kx-worker3kubectl --context kind-kx apply -f checkout.yamlkubectl --context kind-kx get pods -o widekubectl --context kind-kx get events --field-selector reason=Preemptedkubectl --context kind-kx delete -f checkout.yaml -f batch.yaml -f classes.yaml
For your own kind cluster kx: copy a command and paste it into your terminal. Run in the simulator runs the same command in this page's simulated cluster instead; nothing on this page touches your machine. Save the three manifests from this lesson first. Every kind node reports the host's full CPU count, so on a machine with more than five cores raise the batch CPU request until the Allocated resources section of describe shows less than 2 CPU free on each worker, or checkout fits without preempting.
Actual state
Check your understanding
Your first answer to each check is the one that counts. After a miss you can answer again; passing every check reconciles the lesson.
Lesson not yet reconciled
Desired: 4 objectives, 0 metReconciled: 4 of 4 objectives met
- Create PriorityClasses and assign them to workloads. (not yet met)
- Predict which pods the scheduler preempts to place a higher-priority pod. (not yet met)
- Explain why PodDisruptionBudgets are honoured only on a best-effort basis during preemption. (not yet met)
- Use preemptionPolicy Never for work that should queue first without evicting anyone. (not yet met)
Pass every check above to reconcile this lesson.
Every check has passed, so the desired state is met. First-try accuracy: 0 of 5. This lesson's review cards are in your queue.
Practice
Put this lesson to work on the simulated cluster. Everything runs in your browser, with nothing to install.
Changed since the notes
This lesson draws on an earlier set of study notes. Where the documentation contradicts a claim in them, qualifies it or has moved past it, the claim is listed here with the corrected statement and the source it was checked against.
Show 7 corrections
The notes saidKarpenter replaces Cluster Autoscaler and provisions nodes from pending pods
CorrectedTrue. Karpenter v1 APIs are stable: NodePool karpenter.sh/v1, EC2NodeClass karpenter.k8s.aws/v1. The latest AWS provider release is v1.15.2 (2026-11-12). On EKS Auto Mode, AWS runs Karpenter as a managed component and you configure only NodePools.
Sourcegithub.com/aws/karpenter-provider-aws/releases/tag/v1.15.2
The notes saidFargate has no node-level scheduling and each pod is isolated
CorrectedPods that match a Fargate profile get schedulerName: fargate-scheduler, a second scheduler that EKS runs. Each pod runs in its own VM and binds to its own fargate-* Node object, one pod per node. DaemonSets, privileged containers, hostNetwork and hostPort are not supported.
The notes saidThe default scheduler handles thousands of pods per minute
CorrectedThe Kubernetes docs give no throughput figure. Throughput depends on cluster size, plugins and percentageOfNodesToScore. That setting is adaptive: 50% at 100 nodes, falling to 10% at 5000 nodes, with a 5% floor.
Sourcekubernetes.io/docs/concepts/scheduling-eviction/scheduler-perf-tuning
The notes saidkubectl logs -n kube-system kube-scheduler-<node> shows scheduler logs on EKS
CorrectedEKS has no visible kube-scheduler pod. Enable the scheduler control plane log type and read it in CloudWatch Logs under /aws/eks/<cluster>/cluster. The kubectl command works only on self-managed clusters.
Sourcedocs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html
The notes saidMultiple pods are scheduled in parallel through concurrent scheduling cycles
CorrectedScheduling cycles run serially, one pod at a time. Only binding cycles may run concurrently.
Sourcekubernetes.io/docs/concepts/scheduling-eviction/scheduling-framework
The notes saidPDB blocking is a reason pods won't schedule
CorrectedPDBs never block scheduling. They limit voluntary evictions. During preemption the scheduler respects PDBs only on a best-effort basis.
Sourcekubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption
The notes saidRequired pod affinity filters out nodes that don't run the matching pods
CorrectedRequired pod affinity filters by topology domain: a node passes if any node in its topologyKey domain runs a matching pod. That equals 'nodes without those pods' only when topologyKey is kubernetes.io/hostname.
Sourcekubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node
Every correction across the guide, by note and topic.
Sources
Checked against kubernetes.io and AWS documentation for Kubernetes 1.37 on .
- kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption
- kubernetes.io/docs/reference/kubernetes-api/workload-resources/priority-class-v1
- kubernetes.io/docs/concepts/scheduling-eviction/scheduling-framework
- kubernetes.io/docs/concepts/scheduling-eviction/scheduler-perf-tuning
- kubernetes.io/docs/concepts/workloads/pods/disruptions
- kubernetes.io/docs/concepts/scheduling-eviction/node-pressure-eviction
- kubernetes.io/docs/concepts/cluster-administration/flow-control
- docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html
- docs.aws.amazon.com/eks/latest/userguide/fargate.html
- docs.aws.amazon.com/eks/latest/userguide/automode.html
- karpenter.sh/docs/concepts/nodepools
Priority and preemption
↓ ↑ step, 1 to 7 scene, Esc leave