Scheduling and nodesLesson 4 of 10
  1. Requests, limits and quotas, not reconciled
  2. QoS classes and node-pressure eviction, not reconciled
  3. cgroups, memory pressure and the OOM killer, not reconciled
  4. How the scheduler places a pod, not reconciled
    1. The queue
    2. Filter
    3. Score
    4. Bind
    5. Reading Pending
    6. Profiles and extensions
    7. No rebalancing
  5. Affinity, taints and tolerations, not reconciled
  6. Topology spread constraints, not reconciled
  7. Priority and preemption, not reconciled
  8. Nodes and the kubelet, not reconciled
  9. Disruptions and PodDisruptionBudgets, not reconciled
  10. Cluster autoscaling, not reconciled

How the scheduler places a pod

kube-scheduler takes one pending pod at a time through a queue, a set of filters, a round of scoring and a bind. Learn each stage, read a FailedScheduling message node by node, and hold pods back with scheduling gates.

  • 20 min
  • 4 objectives
  • 7 scenes

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.

Reconcile, in 7 scenes

The queue

The kube-schedulerThe control-plane component that assigns each unscheduled pod to a node by writing a Binding; it never starts containers itself. watches the API server for pods whose spec.nodeName is empty and whose spec.schedulerName matches one of its profiles. Every such pod goes into the scheduling queue, which is really three:

  • The active queue holds pods ready for an attempt. It is ordered by the QueueSort plugin, PrioritySort by default: higher priority first, then oldest first.
  • The backoff queue holds pods that failed an attempt and have been cleared to try again, until their backoff expires. Each failure doubles the backoff, from podInitialBackoffSeconds (1 second by default) up to podMaxBackoffSeconds (10 seconds).
  • The unschedulable pods wait for a reason to try again. A pod that failed because no node had enough CPU will not succeed until something changes, so it waits for a cluster event: a node added or uncordoned, a pod deleted, a label changed. Queueing hints, stable since 1.34, let each plugin say which events could make a given pod schedulable, so an unrelated change does not send it round again. The scheduler also flushes these pods back periodically, in case it missed something.

The scheduler takes one pod off the active queue at a time and runs a scheduling cycle for it. Scheduling cycles run serially, never two at once, so every decision sees the reservations made by the decision before it. Inside one cycle the scheduler checks nodes in parallel, 16 at a time by default.

Scheduling gates

Before a pod enters the active queue, PreEnqueue plugins can hold it back. The built-in one reads scheduling gatesA list of names in spec.schedulingGates. While the list is not empty, the scheduler does not try to place the pod., stable since 1.30:

apiVersion: v1
kind: Pod
metadata:
  name: gated
spec:
  schedulingGates:
    - name: example.com/quota-check
  containers:
    - name: app
      image: nginx:1.30

A gated pod is created, admitted and stored, but it never reaches a filter. Each gate stands for a check some other controller must finish, such as a quota system confirming the budget, a batch queue releasing a job, or a provisioner preparing a node. That controller removes its gate when it is done, and the pod enters the queue when the last gate is gone.

A gated pod waits outside the scheduler
kubectl apply -f gated.yaml
pod/gated created
kubectl get pod gated
NAME    READY   STATUS            RESTARTS   AGE
gated   0/1     SchedulingGated   0          0s
kubectl get pod gated -o jsonpath='{.status.conditions[0].reason}'
SchedulingGated
kubectl patch pod gated --type=json -p '[{"op":"remove","path":"/spec/schedulingGates"}]'
pod/gated patched
kubectl get events --field-selector involvedObject.name=gated,reason=Scheduled
LAST SEEN   TYPE     REASON      OBJECT      MESSAGE
0s          Normal   Scheduled   pod/gated   Successfully assigned default/gated to kx-worker3

The rules are strict. Gates can be set only when the pod is created; afterwards they can be removed but never added. While a pod is gated, its scheduling constraints can only be tightened: you can add a nodeSelector entry or narrow a node affinity, not loosen one. Because gated pods never fail a filter, they produce no FailedScheduling events and no Unschedulable condition; the PodScheduled condition says SchedulingGated instead, and the scheduler counts them in scheduler_pending_pods{queue="gated"}.

Gates are the right tool when a pod cannot possibly be placed yet. Without one, an unready pod churns through the queue, earns FailedScheduling events, and makes a node autoscaler such as Cluster Autoscaler or Karpenter add nodes it does not need, since both act on pods the scheduler has marked unschedulable.

Filter

The scheduling cycle starts by finding the feasible nodesThe nodes that pass every Filter plugin for a pod. Only feasible nodes are scored.. PreFilter plugins compute what the filters need once per pod, and then each Filter plugin answers one yes-or-no question about one node:

  • NodeUnschedulable: is the node cordoned (spec.unschedulable: true)?
  • NodeName: if the pod names a node, is this it?
  • TaintToleration: does the pod tolerate every NoSchedule and NoExecute taint on the node?
  • NodeAffinity: does the node match the pod’s nodeSelector and required node affinity?
  • NodePorts: are the pod’s hostPorts free on the node?
  • NodeResourcesFit: do the pod’s requests fit in the node’s allocatable capacity minus the requests of pods already there?
  • VolumeBinding, VolumeZone, VolumeRestrictions, NodeVolumeLimits: can the pod’s volumes be bound and attached here?
  • PodTopologySpread: would placing the pod here break a DoNotSchedule spread constraint?
  • InterPodAffinity: do the pod’s required affinity and anti-affinity rules hold here, and do the rules of pods already running allow it?

A node is rejected by the first filter that fails, and the scheduler records which one. NodeResourcesFit compares requests, never live usage, and PodDisruptionBudgets play no part in any filter.

In a large cluster, checking every node is wasted work. percentageOfNodesToScore stops the search once enough feasible nodes are found. Left unset, it adapts to the cluster’s size: 50% at 100 nodes, falling to 10% at 5,000, with a 5% floor. The scheduler never stops before finding 100 feasible nodes, so a cluster smaller than that is always searched in full. The documentation gives no fixed throughput figure, because throughput depends on cluster size, the enabled plugins and this setting.

If no node passes, PostFilter plugins run. The default one, DefaultPreemption, looks for lower-priority pods whose removal would make the pod fit, and the priority and preemption lesson covers it.

Score

Every feasible node can run the pod; scoring picks the best one. Each Score plugin rates each node from 0 to 100, NormalizeScore plugins rescale where needed, and the scheduler adds up the ratings, each multiplied by its plugin’s weight:

  • NodeResourcesFit prefers nodes by a scoring strategy: LeastAllocated (the default) favours the emptiest nodes and spreads load; MostAllocated packs pods onto the fullest nodes so others can be removed; RequestedToCapacityRatio follows a curve you define.
  • NodeResourcesBalancedAllocation prefers nodes where CPU and memory would end up used in similar proportions.
  • ImageLocality prefers nodes that already hold the pod’s images.
  • TaintToleration prefers nodes with fewer untolerated PreferNoSchedule taints.
  • NodeAffinity, InterPodAffinity and PodTopologySpread add the preferred, soft forms of their rules.

The highest total wins, and ties are broken at random. Scoring is relative: a node that loses here was still feasible, so a pod never goes Pending because of scores.

Bind

The winning node is not yet written anywhere. Reserve plugins first record the decision in the scheduler’s cache, so the next scheduling cycle already counts this pod’s requests against the node. Permit plugins can then approve the pod, deny it, or hold it for a while; co-scheduling plugins use the hold to wait until every pod of a group has a place.

What follows is the binding cycle. PreBind plugins do work that must finish first, such as provisioning a volume. Then the Bind plugin, DefaultBinder unless you configure another, sends a Binding object to the pod’s binding subresource, and the API server sets spec.nodeName. PostBind plugins run afterwards, for cleanup and bookkeeping. Binding cycles can run concurrently, because volume work in PreBind may take seconds and should not stall the queue.

From here the scheduler is done. The kubelet on the named node sees a pod bound to it, admits it against its own view of resources, and starts the containers. The scheduler records a Scheduled event: Successfully assigned default/gated to kx-worker.

Setting spec.nodeName yourself skips the whole pipeline: no queue, no filters, so NoSchedule taints and cordons are ignored. A NoExecute taint on the node still evicts the pod, and the kubelet may refuse it with a reason such as OutOfcpu; nothing then tries another node. Use nodeSelector or node affinity instead.

ExplainerThe scheduling pipeline

The pending pod web, labelled app=web. The controls edit its YAML.

requests.cpu500m
requests.memory256Mi
nodeSelector disktype
Tolerate dedicated=batch:NoSchedule
Spread app=web pods across zonesmaxSkew 1, whenUnsatisfiable DoNotSchedule

pod.yaml

Tab indents two spaces and Shift+Tab outdents. To leave the editor, press Escape, then Tab.

Edits rerun the scheduler as you type.

Filters, in order

  1. NodeUnschedulable
  2. NodeName
  3. TaintToleration
  4. NodeAffinity
  5. NodePorts
  6. NodeResourcesFit
  7. VolumeBinding
  8. PodTopologySpread
  9. 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 pods

    CPU3050m free of 4000m

    Memory7902Mi free of 8192Mi

    TaintToleration: node(s) had untolerated taint(s)

  • kx-worker

    zone zone-a, disktype=ssd2 app=web pods

    CPU2800m free of 4000m

    Memory6918Mi free of 8192Mi

    Passed all 9 filters

  • kx-worker2

    zone zone-b, disktype=ssdtaint dedicated=batch:NoScheduleno app=web pods

    CPU1400m free of 4000m

    Memory4046Mi free of 8192Mi

    TaintToleration: node(s) had untolerated taint(s)

  • kx-worker3

    zone zone-b, disktype=hdd1 app=web pod

    CPU1400m 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.

Pluginkx-workerkx-worker3
TaintToleration300100 × 3300100 × 3
NodeAffinity00 × 200 × 2
NodeResourcesFit6666 × 15757 × 1
PodTopologySpread00 × 200 × 2
InterPodAffinity00 × 200 × 2
NodeResourcesBalancedAllocation7373 × 17070 × 1
ImageLocality00 × 100 × 1
Total of 1200439427

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.

Change the pod's requests, node selector, toleration and spread constraint, or edit its YAML. Filter plugins rule nodes out one at a time with the scheduler's own reasons, and the nodes that survive are scored. Drag the pod onto a node to create it there and see the scheduler bind it or refuse it.

Reading Pending

A pod stays Pending until it is bound and its containers start. When the cause is scheduling, the scheduler explains itself in a FailedScheduling event and in the pod’s PodScheduled condition, with reason Unschedulable. In this simulator session, kx-worker3 has been cordoned and the pod asks for almost four full CPUs:

apiVersion: v1
kind: Pod
metadata:
  name: big
spec:
  containers:
    - name: app
      image: nginx:1.30
      resources:
        requests:
          cpu: "3950m"
          memory: 512Mi
One verdict per node
kubectl cordon kx-worker3
node/kx-worker3 cordoned
kubectl apply -f big.yaml
pod/big created
kubectl get pod big
NAME   READY   STATUS    RESTARTS   AGE
big    0/1     Pending   0          0s
kubectl get events --field-selector reason=FailedScheduling
LAST SEEN   TYPE      REASON             OBJECT    MESSAGE
0s          Warning   FailedScheduling   pod/big   0/4 nodes are available: 1 node(s) had untolerated taint(s), 1 node(s) were unschedulable, 2 Insufficient cpu. preemption: 0/4 nodes are available: 2 No preemption victims found for incoming pod, 2 Preemption is not helpful for scheduling.

Read it as a histogram. 0/4 is the verdict: no feasible node out of four. Each later phrase is a count of nodes and a reason given by the first filter that rejected them. Here every node fails for one reason, so the counts add up to four; a filter can give a node more than one reason, such as Insufficient cpu and Insufficient memory, and that node is then counted under both:

PhraseFilterNode here
node(s) had untolerated taint(s)TaintTolerationkx-control-plane, with its control-plane taint
node(s) were unschedulableNodeUnschedulablekx-worker3, cordoned
Insufficient cpuNodeResourcesFitkx-worker and kx-worker2, 4 CPUs each, with 100m and 200m already requested by system pods
node(s) didn't match Pod's node affinity/selectorNodeAffinitynone here
node(s) didn't match pod anti-affinity rulesInterPodAffinitynone here
node(s) didn't match pod topology spread constraintsPodTopologySpreadnone here

Because each node is counted once, under its first failure, the message understates what is wrong. kx-worker3 might also lack CPU; you find out only after uncordoning it. The message does not name the taint either; kubectl describe node shows it.

The part after preemption: is DefaultPreemption’s own verdict. No preemption victims found means evicting lower-priority pods could in principle help on that node but no suitable victims exist; Preemption is not helpful means no eviction could fix that node’s failure, such as a taint or a cordon.

Not every Pending pod has an event. Check these when there is none:

  • SchedulingGated status: the pod is gated, as above.
  • A schedulerName no scheduler serves: the pod waits forever, silently. Check spec.schedulerName.
  • No pod at all: the ReplicaSet could not create it, and its FailedCreate events say why.
  • Bound but not running: spec.nodeName is set, so scheduling succeeded; look at the kubelet’s events for image pulls, volume mounts or sandbox creation.

Profiles and extensions

kube-scheduler is configured with a KubeSchedulerConfiguration file. On kind and other kubeadm clusters it runs as a static pod in kube-system, here kube-scheduler-kx-control-plane, and kubectl -n kube-system logs reads its log. Managed control planes hide the scheduler; their providers expose its logs through their own control plane logging instead.

One scheduler process can run several profiles, each a scheduling profileA named configuration of plugins inside one kube-scheduler. A pod selects a profile by setting spec.schedulerName to the profile’s name. with its own plugin settings:

apiVersion: kubescheduler.config.k8s.io/v1
kind: KubeSchedulerConfiguration
profiles:
  - schedulerName: default-scheduler
  - schedulerName: bin-packing
    pluginConfig:
      - name: NodeResourcesFit
        args:
          scoringStrategy:
            type: MostAllocated
            resources:
              - name: cpu
                weight: 1
              - name: memory
                weight: 1

A pod opts in with spec.schedulerName: bin-packing; pods that set nothing get default-scheduler, filled in by the API server. All profiles share one queue, so they must agree on the QueueSort plugin. Profiles are cheaper and safer than a second scheduler binary: two separate schedulers each keep their own view of free capacity and can both place pods into the same space, while profiles in one process share one cache.

Plugins hook into named extension points. For one pod, in pipeline order, they are PreEnqueue, QueueSort, PreFilter, Filter, PostFilter, PreScore, Score, NormalizeScore, Reserve (with Unreserve, which rolls a reservation back when a later stage fails), Permit, PreBind, Bind and PostBind; plugins also register queueing hints through EnqueueExtension. Gang scheduling of pod groups, beta in 1.37, adds extension points of its own, such as placementGenerate and placementScore. A profile can enable, disable or reweight plugins at each point, and custom plugins are compiled into a scheduler build of your own. The v1 configuration API is the only one served; v1beta3 was removed in 1.29.

No rebalancing

The scheduler decides once per pod, at the moment the pod is pending. It never revisits a decision and never moves a running pod. A pod cannot change nodes at all: spec.nodeName is immutable once set, so “moving” a pod always means deleting it and letting its controller create a replacement, which goes through the queue like any other.

That has consequences you can predict. Add a node and it stays empty until pods are created. Relabel a node or add a NoSchedule taint after its pods were placed, and they stay where they are; the IgnoredDuringExecution in node affinity’s field names says exactly that. Only a NoExecute taint removes running pods, and the taint-eviction controller does that, not the scheduler. Lose a node and its replacements crowd onto whatever is left, and they stay there after the node comes back.

To redistribute on purpose:

  • Roll the workload. kubectl rollout restart deployment/<name> replaces every pod, and each replacement is scheduled against the cluster as it stands at that moment.
  • Run the descheduler. This kubernetes-sigs project evicts pods that sit on poorly chosen nodes, by rules such as RemoveDuplicates, LowNodeUtilization or RemovePodsViolatingNodeTaints. It uses the Eviction API, so PodDisruptionBudgets are respected, and it leaves placing the replacements to the scheduler.
  • Let the node autoscaler consolidate. Cluster Autoscaler and Karpenter (whose NodePool API is stable as karpenter.sh/v1) add nodes for unschedulable pods, and remove or replace underused ones by evicting their pods.

Read a verdict on your own cluster

  1. kubectl --context kind-kx create deployment big --image=nginx:1.30
  2. kubectl --context kind-kx set resources deployment big --requests=cpu=64
  3. kubectl --context kind-kx get events --field-selector reason=FailedScheduling
  4. kubectl --context kind-kx -n kube-system logs kube-scheduler-kx-control-plane --tail=20
  5. kubectl --context kind-kx delete deployment big

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. The new ReplicaSet's pod asks for 64 CPUs, which fits no kind node, so every worker reports Insufficient cpu and the control-plane node reports its taint. The first pod, created before the request was set, keeps running.

Actual state

Check your understanding

5 checks

Your first answer to each check is the one that counts. After a miss you can answer again; passing every check reconciles the lesson.

  1. Check 1 of 5

    A pod is Pending with 0/4 nodes are available: 1 node(s) had untolerated taint(s), 1 node(s) were unschedulable, 2 Insufficient cpu. Which change lets it schedule without touching the pod?

  2. Check 2 of 5

    How does kube-scheduler handle many pending pods at once?

  3. Check 3 of 5

    A pod shows status SchedulingGated. What do you find in its events?

  4. Check 4 of 5

  5. Check 5 of 5

    A Deployment's 6 pods all run on two nodes. You add a third node. What happens to the running pods?

Lesson not yet reconciled

Desired: 4 objectives, 0 metReconciled: 4 of 4 objectives met

  • Walk a pod through the scheduling queue, filtering, scoring and binding. (not yet met)
  • Read a FailedScheduling message and name the filter that rejected each node. (not yet met)
  • Explain what scheduling gates do and when to use them. (not yet met)
  • Explain why the scheduler never moves a running pod, and what to use instead. (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
  1. Nuance, true with conditionsKubernetes Scheduler Deep Dive

    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

  2. Wrong, not trueKubernetes Scheduler Deep Dive

    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.

    Sourcedocs.aws.amazon.com/eks/latest/userguide/fargate.html

  3. Nuance, true with conditionsKubernetes Scheduler Deep Dive

    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

  4. Wrong, not trueKubernetes Scheduler Deep Dive

    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

  5. Wrong, not trueKubernetes Scheduler Deep Dive

    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

  6. Wrong, not trueKubernetes Scheduler Deep Dive

    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

  7. Nuance, true with conditionsKubernetes Scheduler Deep Dive

    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 .

  1. kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler
  2. kubernetes.io/docs/concepts/scheduling-eviction/scheduling-framework
  3. kubernetes.io/docs/concepts/scheduling-eviction/pod-scheduling-readiness
  4. kubernetes.io/docs/reference/scheduling/config
  5. kubernetes.io/docs/reference/config-api/kube-scheduler-config.v1
  6. kubernetes.io/docs/concepts/scheduling-eviction/scheduler-perf-tuning
  7. kubernetes.io/docs/tasks/extend-kubernetes/configure-multiple-schedulers
  8. kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption
  9. kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration
  10. kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node
  11. github.com/kubernetes-sigs/descheduler

How the scheduler places a pod

↓ ↑ step, 1 to 7 scene, Esc leave

kind cluster kxLast command: Nothing run yet