
On this page
You run kubectl apply, the Deployment is created, the ReplicaSet makes its Pods, and then nothing. kubectl get pods says Pending, and it keeps saying it. Somewhere between "the Pod exists" and "the Pod is running", one component made a decision, or refused to make one: the kube-scheduler.
In the first part of Kubernetes Internals: How a Cluster Really Works, we followed a request through the API server and ended with a chain reaction: controllers created Pods, and "the scheduler sees Pods with no node assigned, picks a node for each, and writes a binding". This part opens that box. You will see how the scheduler queues Pods, how it filters and scores nodes, how it binds a Pod and when it evicts others to make room. Then we turn it around: given a Pod stuck in Pending, how to read the scheduler's message and fix the cause.
New to the series? Start with Kubernetes API Server Explained: The Life of a Request.
What Is the Kubernetes Scheduler?
Definition: The Kubernetes scheduler (kube-scheduler) is the control plane component that assigns each new Pod to a node. It watches for Pods with no node, filters out the nodes that cannot run them, scores the rest, and records its choice by writing a binding through the API server.
Three facts frame the rest of this article:
- It only decides. The scheduler never starts a container. Its whole output is one field,
spec.nodeName, set through the Pod'sbindingsubresource. The kubelet on that node sees the change through its watch and does the work. - It decides from requests, not from usage. A node that runs at 5% CPU can still be "full" if its Pods requested all of it. The scheduler counts what Pods asked for in
resources.requests, never what they are using right now. - It is one Pod at a time. The scheduler takes one Pod from its queue, finds it a node, and moves on to the next. Placing a group of Pods well is the job of constraints you write on each Pod, such as spread and affinity, not of a global plan.
The scheduler is a client of the API server like any other. It watches Pods and Nodes (and PersistentVolumes, CSI nodes and more), keeps them in an in-memory cache, and writes its decisions back. In a highly available control plane, several replicas run, but only the one holding the kube-scheduler Lease in kube-system is active; the others wait to take over.
Which Pods It Picks Up
The scheduler only handles Pods that have no node yet and that name it. Every Pod has spec.schedulerName, which defaults to default-scheduler. A Pod that names another scheduler, perhaps one that was never installed, is ignored by the default one. It stays Pending forever, with no event at all.
A Pod created with spec.nodeName already set skips the scheduler entirely. The kubelet on that node runs it directly, which is how static Pods work and why setting nodeName by hand bypasses every check in this article.
The Kubernetes Scheduling Cycle at a Glance
Each Pod goes through two phases. The scheduling cycle picks a node, and runs for one Pod at a time. The binding cycle applies the choice, and can run for several Pods at once while the next scheduling cycle starts.
How kube-scheduler places a Pod, step by step:
- A Pod with no
nodeNameappears in the scheduler's watch and joins the scheduling queue. - The scheduler pops the highest-priority Pod from the queue.
- Filter: every node that cannot run the Pod is removed: not enough resources, an untolerated taint, an affinity that does not match.
- Score: each remaining node gets a score from several plugins, and the scores are weighted and added up.
- The node with the highest total wins; a tie is broken at random.
- Reserve: the scheduler assumes the Pod is on that node in its own cache, so the next Pod sees the space as taken.
- Bind: asynchronously, the scheduler prepares volumes if needed and writes a
Bindingto the API server, which setsspec.nodeName.
If no node passes the filters, the scheduler records a FailedScheduling event, may try preemption, and puts the Pod back in the queue to wait for a change in the cluster.
The Scheduling Queue: Where Pending Pods Wait
The queue is not one list. It has three parts, and a Pending Pod is always in one of them:
| Part | What it holds | How a Pod leaves |
|---|---|---|
| activeQ | Pods ready to be tried now | Popped by the scheduling cycle, highest priority first |
| backoffQ | Pods that failed recently and must wait | Its backoff ends: 1 s after the first failure, doubling with each one, up to 10 s |
| Unschedulable | Pods that failed and wait for something to change | A cluster event that might help it, or a periodic flush, at most five minutes later |
Within activeQ, the default PrioritySort plugin orders Pods by their priority, then by the time they were added. A Pod from a system-cluster-critical DaemonSet goes ahead of your batch job.
Why a Failed Pod Is Not Retried in a Loop
When a Pod fails every filter, retrying it at once would fail again: nothing has changed. So the scheduler parks it in the unschedulable pool and waits for a cluster event: a node added, a node's allocatable changed, a Pod deleted, a PersistentVolume created. Each scheduler plugin registers the events that could change its verdict.
When such an event arrives, the Pod moves back to activeQ, or to backoffQ if its backoff has not expired yet. As a safety net, Pods that waited too long in the unschedulable pool are flushed back anyway.
Queueing Hints
Registering an event kind is coarse. A Node update may be a new label, a heartbeat condition or more allocatable CPU, and only the last can help a Pod that failed on Insufficient cpu. Queueing hints let a plugin look at the change itself and answer Queue or QueueSkip. The NodeResourcesFit plugin, for example, skips a Node update that does not add allocatable resources.
Queueing hints are stable since Kubernetes 1.34 and on by default. Their effect is fewer wasted attempts: each retry that is bound to fail is a full scheduling cycle the scheduler could have spent on another Pod. Recent releases also take a Pod from backoffQ early when activeQ is empty, so an idle scheduler rarely makes a Pod wait out its full backoff.
The canvas below plays the same twenty seconds twice. One Pod is Pending on a full cluster while unrelated Node updates arrive, until a new node joins. Compare how often each scheduler tries the Pod before that node exists.
Two timelines of the same twenty seconds. One Pod waits on a full cluster while Node updates that add no CPU arrive, until a new node joins at 16 s. Without queueing hints, each Node update sends the Pod back for an attempt that fails: at the default five updates, seven attempts, six of them failures. With hints, the plugin that rejected the Pod sees no update added CPU and skips them: two attempts, one at the start and one when the node joins. Both place the Pod at 16 s. Node updates sets how many arrive.
Both schedulers place the Pod at the same moment, the moment the node joins. The difference is the attempts before it: without hints, every unrelated Node update cost a full scheduling cycle that was certain to fail.
Scheduling Gates: Pods That Are Not Ready to Be Tried
A Pod can also be held back before it reaches the queue at all. Scheduling gates are names listed in spec.schedulingGates; while any remain, the scheduler leaves the Pod alone, and kubectl get pods shows its status as SchedulingGated. A controller removes each gate when the Pod is ready, for example once a quota system has admitted it. Gates can only be set when the Pod is created and only removed afterwards. The feature is stable since Kubernetes 1.30.
The Scheduling Framework and Its Extension Points
Every step of the scheduler is a plugin, called at a named point of the cycle. The default behaviour you know (resource fit, taints, affinity, spread) is just the set of plugins in the default profile. The same points are where custom schedulers plug in.
| Extension point | Cycle | What happens there | Default plugins (examples) |
|---|---|---|---|
| PreEnqueue | Queue | Decide whether the Pod may enter activeQ at all | SchedulingGates |
| QueueSort | Queue | Order activeQ | PrioritySort |
| PreFilter | Scheduling | Precompute state for the Pod, reject early | NodeResourcesFit, NodePorts, PodTopologySpread, InterPodAffinity, VolumeBinding |
| Filter | Scheduling | Reject each node that cannot run the Pod | NodeUnschedulable, NodeName, TaintToleration, NodeAffinity, NodeResourcesFit, VolumeBinding |
| PostFilter | Scheduling | Runs only when no node passed: try to make room | DefaultPreemption |
| PreScore, Score | Scheduling | Rate each node that passed | NodeResourcesFit, NodeResourcesBalancedAllocation, ImageLocality, TaintToleration, NodeAffinity, PodTopologySpread, InterPodAffinity |
| NormalizeScore | Scheduling | Bring each plugin's scores to the same range | (per plugin) |
| Reserve | Scheduling | Hold the node's resources in the cache; undone by Unreserve on failure | VolumeBinding |
| Permit | Scheduling | Approve, deny or make the Pod wait | (none by default; used for gang scheduling) |
| PreBind | Binding | Work that must finish before the bind, such as binding volumes | VolumeBinding |
| Bind | Binding | Write the binding to the API server | DefaultBinder |
| PostBind | Binding | Clean up after a successful bind | (none by default) |
Two properties are worth remembering. Scheduling cycles run serially, binding cycles may run concurrently: the slow part, talking to the API server, does not block the next decision. And Filter runs in parallel across nodes: on a large cluster, the scheduler checks many nodes at once.
Filtering: Which Nodes Can Run the Pod?
Filtering is a series of yes-or-no questions asked of each node. A node that fails any filter is out, and the scheduler remembers why. That reason, counted across nodes, is the message you will read later in FailedScheduling.
Resources: Requests Against Allocatable
NodeResourcesFit adds the requests of every Pod already on the node to the requests of the new Pod and compares the total with the node's allocatable resources: its capacity minus what is reserved for the system and the kubelet. If CPU, memory, ephemeral storage or any extended resource (such as nvidia.com/gpu) would go over, the node fails with Insufficient cpu, Insufficient memory, and so on. A node also has a maximum number of Pods, 110 by default, and a full one fails with Too many pods.
kubectl describe node worker-2 | sed -n '/Allocatable/,/Events/p'The Allocated resources table in that output shows exactly what the scheduler counts: the sum of requests and limits of the Pods on the node, as a share of allocatable. A node can show 95% of its CPU requested while kubectl top node reports 10% in use. For the scheduler, that node is nearly full.
The Pod's own request is its effective request: the larger of its biggest init container and the sum of its app containers, plus any Pod overhead. Sidecar containers, which are init containers with restartPolicy: Always, are counted with the app containers. A Pod with no requests at all counts as zero here and fits anywhere, which is one reason BestEffort Pods are easy to schedule and easy to overpack.
Taints and Tolerations
A taint on a node repels Pods; a toleration on a Pod lets it ignore a matching taint. The TaintToleration filter rejects a node if it has a taint with the effect NoSchedule or NoExecute that the Pod does not tolerate. A taint with PreferNoSchedule never filters; it only lowers the node's score.
Several taints are added by Kubernetes itself, and they are behind many Pending Pods:
| Taint | Added when |
|---|---|
node-role.kubernetes.io/control-plane:NoSchedule |
The node is a kubeadm control plane node |
node.kubernetes.io/not-ready:NoSchedule |
The node's Ready condition is false |
node.kubernetes.io/unreachable:NoSchedule |
The node controller cannot reach the node |
node.kubernetes.io/disk-pressure:NoSchedule |
The kubelet reports disk pressure (also memory and PID pressure) |
node.kubernetes.io/unschedulable:NoSchedule |
The node is cordoned |
kubectl get nodes -o custom-columns='NAME:.metadata.name,TAINTS:.spec.taints[*].key'Node Selectors and Node Affinity
nodeSelector and the requiredDuringSchedulingIgnoredDuringExecution part of node affinity are filters: a node whose labels do not match is out. The preferred… part only scores. A selector on a label that no node has, perhaps a typo in topology.kubernetes.io/zone, makes every node fail.
Pod Topology Spread and Pod Affinity
PodTopologySpread keeps matching Pods spread across a topology such as zones or nodes. With whenUnsatisfiable: DoNotSchedule, a node is rejected when placing the Pod there would make the spread worse than maxSkew allows. InterPodAffinity checks the Pods already running: required affinity demands a node near certain Pods, and required anti-affinity forbids one, which is how "one replica per node" rules are written. Both look at the Pods on every candidate node, and required anti-affinity in particular is one of the most expensive checks on a large cluster.
Volumes, Ports and Cordons
- VolumeBinding checks that the Pod's PersistentVolumeClaims can be bound on the node: an existing PV whose node affinity matches it, or a StorageClass that can provision one there. VolumeZone and NodeVolumeLimits check the volume's zone and the node's limit on attached volumes.
- NodePorts rejects a node where a requested
hostPortis already in use. - NodeUnschedulable rejects a cordoned node (
spec.unschedulable: true), unless the Pod tolerates theunschedulabletaint. - NodeName rejects every node except the one named, when the Pod sets
spec.nodeName.
Large Clusters: Not Every Node Is Checked
On a cluster of thousands of nodes, filtering and scoring every node for every Pod would be slow. The scheduler stops filtering once it has found enough feasible nodes, then scores only those. The default share is computed from the cluster's size: 50% of nodes on a 100-node cluster, falling to 10% at 5,000 nodes, and never below 5%. It always checks at least 100 nodes, so smaller clusters are checked in full. You can set percentageOfNodesToScore in the scheduler's configuration, but the defaults are a good trade between speed and placement quality. Each cycle also starts where the last one stopped, so every node gets its turn.
Scoring: Which Node Is Best?
Every node that passed the filters is now possible. Scoring decides which is best. Each score plugin gives each node a number from 0 to 100, the numbers are multiplied by the plugin's weight, and the totals are compared. The node with the highest total wins, and a tie is broken at random.
The Default Score Plugins
| Plugin | Prefers nodes that… | Default weight |
|---|---|---|
| TaintToleration | have fewer PreferNoSchedule taints the Pod does not tolerate |
3 |
| NodeAffinity | match more of the Pod's preferred node affinity terms | 2 |
| PodTopologySpread | keep the spread of matching Pods more even | 2 |
| InterPodAffinity | match more of the Pod's preferred Pod affinity terms | 2 |
| NodeResourcesFit | score best under the configured strategy (below) | 1 |
| NodeResourcesBalancedAllocation | would have their CPU and memory used in similar proportions | 1 |
| ImageLocality | already have the Pod's container images | 1 |
The weights are those of the default profile in recent releases. They explain why a preference you wrote, a preferred affinity or a soft spread constraint, usually beats the resource-based plugins: those weigh twice as much.
LeastAllocated vs MostAllocated
NodeResourcesFit scores with one of three strategies:
- LeastAllocated (the default) prefers the node with the most room left. For each resource, the score is the share of allocatable that would still be free after the Pod is placed, and CPU and memory are averaged with equal weight. Load spreads out.
- MostAllocated prefers the fullest node that still fits. It packs Pods tightly, leaving whole nodes empty for the cluster autoscaler to remove.
- RequestedToCapacityRatio lets you draw your own curve from utilization to score, per resource.
For scoring only, a container with no requests is counted as if it asked for 100m of CPU and 200 MiB of memory, so BestEffort Pods do not all pile onto one node.
Seeing Filter and Score Together
Five worker nodes, each with 4 CPU and 16 GiB allocatable, and a Pod that asks for 2 GiB of memory. Change the Pod's CPU request, let it tolerate the GPU node's taint, or switch the scoring strategy, and see which nodes are filtered out and which one wins.
Five worker nodes, each with 4 CPU and 16 GiB allocatable, and a Pod that requests 2 GiB of memory. Each row shows a node's requested CPU with the Pod's on top, then why it is filtered out or its NodeResourcesFit score. At 1 CPU, node-a lacks CPU, node-c has a GPU taint and node-e is in another zone; LeastAllocated picks node-b (31) and MostAllocated node-d (81). Tolerating the taint makes node-c win under LeastAllocated (43). Above 3 CPU no node fits. The controls set the request, the toleration and the strategy.
At the default 1 CPU, node-a is filtered out for CPU, node-c for its taint and node-e for its zone. Of the two that remain, LeastAllocated picks node-b, which has more CPU left, while MostAllocated picks node-d, the fuller one. Raise the request past 3 CPU and no node fits: the status line shows the same kind of message as FailedScheduling.
Binding: How the Decision Reaches the Node
When the scheduling cycle has a winner, the scheduler does not wait for the API server. It assumes the Pod is on the chosen node in its own cache. The next Pod, scheduled a few milliseconds later, already sees that node's resources as taken. This is optimistic: if the bind later fails, the assumption is undone and the Pod returns to the queue.
Then the binding cycle runs in the background:
- Permit plugins can hold the Pod, for example until every member of a group has a node. By default, none do.
- PreBind finishes what the node needs first. VolumeBinding binds PersistentVolumeClaims that waited for a node (
volumeBindingMode: WaitForFirstConsumer) and waits for the volume to be provisioned. - Bind sends a
POSTto the Pod'sbindingsubresource:
POST /api/v1/namespaces/team-a/pods/web-0/binding{
"apiVersion": "v1",
"kind": "Binding",
"metadata": { "name": "web-0" },
"target": { "apiVersion": "v1", "kind": "Node", "name": "worker-2" }
}That request walks the whole API server pipeline from part one: the scheduler authenticates as system:kube-scheduler, RBAC allows it to create pods/binding, and the API server sets spec.nodeName and the PodScheduled condition to True. The kubelet on worker-2 sees the change in its watch and starts the Pod.
The Kubelet Has the Last Word
The kubelet checks the Pod again before running it. If its view differs from the scheduler's, for example because a static Pod took the space, it rejects the Pod, which then fails with a reason such as OutOfcpu or OutOfmemory. This is rare with the scheduler, and common when people set nodeName by hand.
Pod Priority and Preemption: Making Room
What if no node passes the filters, but the Pod matters more than what is already running? That is what priority and preemption are for.
A PriorityClass maps a name to an integer; a Pod names it in spec.priorityClassName, and higher numbers win. Two classes are built in: system-cluster-critical and system-node-critical, for the components a cluster cannot run without. A Pod with no class gets priority 0, or the value of a class marked globalDefault.
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: business-critical
value: 100000
globalDefault: false
description: "Customer-facing services. May preempt batch jobs."Priority already orders the scheduling queue. Preemption goes further, and runs in the PostFilter step, only when filtering left no node:
- For each node, the DefaultPreemption plugin asks: if every Pod with a lower priority were removed, would the new Pod fit?
- On each node where it would, it gives back as many of those Pods as it can while the new Pod still fits. The rest are the victims.
- It picks the node where the cost is lowest: the fewest PodDisruptionBudget violations first, then the lowest-priority victims, and the fewest of them.
- It sets the Pod's
status.nominatedNodeNameto that node and deletes the victims, which get their normal graceful termination period, 30 seconds by default. - The Pod goes back to the queue. When the victims are gone, it is scheduled like any other Pod.
Some details surprise people:
- PodDisruptionBudgets are respected on a best-effort basis. The scheduler prefers victims that do not break a PDB, but if it cannot find any, it preempts anyway.
- The Pod may not land on the nominated node. If another node frees up first, or a Pod of even higher priority takes the space, it goes elsewhere.
nominatedNodeNameis a reservation hint, not a binding. - QoS class plays no part. Only priority decides who is preempted.
- Preemption can be switched off per class with
preemptionPolicy: Never. Such Pods still go ahead of others in the queue, but wait for room instead of making it.
Preemption also explains a strange line in many FailedScheduling messages, after the word preemption:. When it says No preemption victims found for incoming pod, preemption looked and found nothing of lower priority to remove.
Why Pods Stay Pending
Pending is a Pod phase, and it covers more than the scheduler. A Pod is Pending from the moment it is created until all its containers have started, so there are two very different kinds of Pending Pods.
Two Kinds of Pending
kubectl get pod web-0 -o jsonpath='{.status.conditions[?(@.type=="PodScheduled")]}{"\n"}'PodScheduledisFalse: the scheduler has not placed the Pod. The condition's reason isUnschedulable(no node fits) orSchedulingGated(gates remain). This is the subject of this section.PodScheduledisTrue: the Pod has a node, and the wait is on that node. The container status says why:ContainerCreating,ErrImagePull,ImagePullBackOff, or a volume that fails to attach or mount (FailedAttachVolume,FailedMountevents). The scheduler is done; look at the kubelet, the registry or the storage driver.
kubectl get pod -o wide shows the difference at a glance: a Pod the scheduler has not placed has <none> in the NODE column.
Reading a FailedScheduling Event
When the scheduler cannot place a Pod, it records a Warning event with the reason FailedScheduling. kubectl describe pod shows it under Events:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 12s default-scheduler 0/6 nodes are available: 1 node(s) had untolerated taint {node-role.kubernetes.io/control-plane: }, 2 Insufficient cpu, 3 node(s) didn't match Pod's node affinity/selector. preemption: 0/6 nodes are available: 2 No preemption victims found for incoming pod, 4 Preemption is not helpful for scheduling.Read it in three parts:
0/6 nodes are available: the cluster has six nodes, and none passed every filter.- The reasons, with a count of nodes for each: one node is the control plane, two do not have enough CPU, three are in the wrong place for the Pod's selector or affinity. A node rejected for several resources at once, both CPU and memory, is counted under each, so the counts can add up to more than the number of nodes.
preemption:: what preemption found. On the two nodes short of CPU, there was nothing of lower priority to evict. On the other four, evicting Pods would not help, since a taint or a label is not something preemption can change.
The fix comes from the largest group you can act on. Here, either the three nodes need the label the selector asks for, or the Pod needs less CPU, or the cluster needs another node.
To list every scheduling failure in a namespace:
kubectl get events -n team-a --field-selector reason=FailedScheduling --sort-by=.lastTimestampCommon FailedScheduling Messages and Their Fixes
| Message | What it means | Fix |
|---|---|---|
Insufficient cpu / Insufficient memory |
The node's allocatable minus existing requests is less than the Pod's request | Lower the request, free capacity, or add nodes (an autoscaler does this) |
Too many pods |
The node has reached its maximum Pod count | Add nodes, or raise the kubelet's maxPods if the node and its network allow it |
node(s) had untolerated taint {key: value} |
A NoSchedule or NoExecute taint the Pod does not tolerate |
Add a toleration if the Pod belongs there; otherwise the taint is doing its job |
node(s) didn't match Pod's node affinity/selector |
Required node affinity or nodeSelector matches no label on the node |
Fix the label or the selector; check for typos and for zones with no nodes |
node(s) didn't match pod topology spread constraints |
Placing the Pod would make the spread worse than maxSkew |
Add nodes in the short zone, raise maxSkew, or use ScheduleAnyway |
node(s) didn't match pod anti-affinity rules |
A required anti-affinity forbids every remaining node | More nodes than replicas, or a preferred rule instead of a required one |
node(s) were unschedulable |
The node is cordoned | kubectl uncordon it when maintenance is over |
node(s) didn't have free ports for the requested pod ports |
A hostPort the Pod asks for is already in use |
Drop hostPort if you can; use a Service instead |
pod has unbound immediate PersistentVolumeClaims |
A PVC with Immediate binding has no volume yet |
Check the PVC's events and its StorageClass's provisioner |
node(s) had volume node affinity conflict |
The Pod's volume lives in a zone where the remaining nodes are not | Schedule in the volume's zone, or use WaitForFirstConsumer for new volumes |
Two Pending Pods produce no FailedScheduling event at all, and are the hardest to spot:
- A wrong
schedulerName. No scheduler claims the Pod, so nothing writes an event. Checkkubectl get pod web-0 -o jsonpath='{.spec.schedulerName}'. - Scheduling gates. The status says
SchedulingGated; list them withkubectl get pod web-0 -o jsonpath='{.spec.schedulingGates}'and find the controller that should remove them.
And one that looks like a scheduling problem but is not: a ResourceQuota. A Pod that would exceed its namespace's quota is refused by admission in the API server and never created, so there is no Pending Pod to describe. The ReplicaSet shows a FailedCreate event with exceeded quota instead: look there with kubectl describe rs.
A Decision Tree for Pending Pods
Debugging a Pending Pod Step by Step
When a Pod stays Pending, these steps find the cause in a few minutes.
1. Has it been scheduled?
kubectl get pod web-0 -o wideA node in the NODE column means the scheduler is done: go to step 5.
2. What did the scheduler say?
kubectl describe pod web-0 | sed -n '/^Events:/,$p'Read the FailedScheduling message as above. No event at all means a gate or the wrong scheduler.
3. What does the Pod ask for?
kubectl get pod web-0 -o jsonpath='{range .spec.containers[*]}{.name}{"\t"}{.resources.requests}{"\n"}{end}'
kubectl get pod web-0 -o yaml | grep -A20 -E 'nodeSelector|affinity|tolerations|topologySpreadConstraints'A request copied from another environment, cpu: "8" on a cluster of 4-CPU nodes, can never fit, and no amount of waiting fixes it.
4. What do the nodes have?
kubectl describe nodes | grep -A8 'Allocated resources'
kubectl get nodes --show-labelsCompare requested with allocatable, and the labels with the Pod's selector.
5. Scheduled but still Pending? Then look at the node, not the scheduler: the container's state in kubectl describe pod, image pull errors, and volume events.
Scheduler Logs and Metrics
The scheduler's own logs say little at the default verbosity; at -v=4 and above it logs each attempt. On a kubeadm cluster:
kubectl logs -n kube-system -l component=kube-scheduler --tail=100On managed clusters, the scheduler's logs are part of the control plane logs your provider can export.
Its metrics show the queue from the outside, and are worth an alert:
scheduler_pending_pods: Pods in the queue, byqueue(active,backoff,unschedulable,gated). A steady rise inunschedulablemeans the cluster is out of something.scheduler_schedule_attempts_total: attempts byresult(scheduled,unschedulable,error).scheduler_scheduling_attempt_duration_seconds: how long each attempt takes, by result and profile.scheduler_preemption_attempts_totalandscheduler_preemption_victims: how often Pods are evicted to make room.
sum by (queue) (scheduler_pending_pods)Pending Pods and the Cluster Autoscaler
A cluster autoscaler, such as Cluster Autoscaler or Karpenter, watches for exactly these Pods: PodScheduled false with the reason Unschedulable. It simulates the scheduler's filters on a new node of each type it may create, and adds one where the Pod would fit. This is why the fix for Insufficient cpu on such a cluster is often just to wait a minute. The autoscaler cannot help when no node type would pass: a selector on a label it never sets, a request larger than its largest instance, or a volume in a zone it does not cover. Look for its own events on the Pod, such as NotTriggerScaleUp, which say why.
Configuring the Scheduler
The scheduler's behaviour comes from a KubeSchedulerConfiguration file, passed with --config. Most clusters never change it, but a few settings are useful to know. The file holds profiles: each has a schedulerName and its own plugins, so one scheduler process can serve several scheduling policies.
apiVersion: kubescheduler.config.k8s.io/v1
kind: KubeSchedulerConfiguration
profiles:
- schedulerName: default-scheduler
- schedulerName: bin-packing-scheduler
pluginConfig:
- name: NodeResourcesFit
args:
scoringStrategy:
type: MostAllocated
resources:
- name: cpu
weight: 1
- name: memory
weight: 1A Pod opts into the second profile with schedulerName: bin-packing-scheduler. Batch workloads that should pack tightly can use it, while services keep spreading under the default profile.
Profiles can also enable or disable plugins at each extension point, and change score weights. On managed clusters, you usually cannot change the default scheduler's configuration; you can run a second scheduler as a Deployment with its own name, and point Pods at it.
Key Takeaways
- The scheduler's only output is a binding: it sets
spec.nodeName, and the kubelet does the rest. - It decides from resource requests against node allocatable, never from actual usage.
- Each Pod goes through filtering, which removes nodes that cannot run it, then scoring, which ranks the rest. The highest weighted score wins.
- Pending Pods wait in a queue with three parts: activeQ, backoffQ and an unschedulable pool that cluster events, filtered by queueing hints, bring them out of.
- Preemption evicts lower-priority Pods when nothing fits, respects PodDisruptionBudgets only on a best-effort basis, and nominates a node without guaranteeing it.
Pendingcovers two cases: not scheduled (PodScheduled=False), and scheduled but waiting on images or volumes. Check the condition first.- A
FailedSchedulingmessage counts nodes per reason; fix the largest group you can act on. - No event at all means a scheduling gate or a
schedulerNameno scheduler serves.
FAQ
What does the Kubernetes scheduler do?
It assigns each new Pod to a node. It filters out the nodes that cannot run the Pod, scores the rest, picks the best one, and writes a binding to the API server. It does not start containers; the kubelet on the chosen node does.
Why is my Pod stuck in Pending?
Run kubectl describe pod and read the events. A FailedScheduling event means no node passed the scheduler's filters, and its message lists why, such as insufficient CPU or an untolerated taint. If the Pod already has a node, it is waiting on that node instead: an image pull or a volume.
What does "0/3 nodes are available" mean?
It means the cluster has three nodes and none of them passed every filter for this Pod. The rest of the message counts the nodes per reason, such as 2 Insufficient memory, 1 node(s) had untolerated taint. Fix the reason that covers the nodes you want the Pod on.
Does the Kubernetes scheduler look at actual CPU usage?
No. The default scheduler compares the sum of the Pods' resource requests with each node's allocatable resources. A node at low real usage can still be full for the scheduler, and a node at high usage can still accept Pods with small requests.
How does the scheduler choose between nodes that fit?
Each score plugin rates every node from 0 to 100, and the ratings are multiplied by the plugin's weight and added. Preferred affinity, topology spread and taints weigh more than resource balance in the default profile. The highest total wins, and ties are broken at random.
What is preemption in Kubernetes?
When no node can run a Pod, the scheduler may evict Pods of lower priority to make room. It picks the node where the fewest and least important Pods must go, marks the waiting Pod with nominatedNodeName, and deletes the victims with their normal grace period.
What is the difference between a taint and node affinity?
A taint is on the node and keeps Pods away unless they tolerate it. Node affinity is on the Pod and pulls it toward nodes with certain labels. To give a team its own nodes, you usually need both: a taint so other Pods stay off, and affinity so the team's Pods go there.
What's Next
You have followed a Pod from the queue to a node, and seen why some never leave the queue. The binding was the scheduler's last word; from here, the kubelet on the node takes over. In the next part of Kubernetes Internals: How a Cluster Really Works, Kubelet and Container Runtimes: How Kubernetes Runs Pods, we follow the Pod onto its node: how the kubelet talks to containerd and runc through the CRI, and how probes, restarts and evictions keep it running.



Comments
No comments yet.
Join the discussion
Sign in to ask a question or share what worked for you.