Interview Prep/Kubernetes/Architecture & Control Plane

What does the kube-scheduler do?

BeginnerConceptArchitecture & Control Plane
Answer

Short answer

The kube-scheduler decides which node each new Pod should run on. It looks at all nodes, removes the ones that can't run the Pod, scores the rest, and picks the best one.

Explained in simple words

Think of a hotel receptionist assigning rooms. A guest asks for a room with two beds, on a non-smoking floor, near the lift. The receptionist first crosses out rooms that don't match, then picks the best of the remaining ones. The scheduler does the same for Pods and nodes.

How it works, step by step

  1. A new Pod is created without a node assigned (spec.nodeName is empty) — it shows as Pending.
  2. Filtering — the scheduler removes nodes that can't run it:
    • Not enough free CPU or memory for the Pod's requests
    • Node has a taint the Pod doesn't tolerate
    • Pod's nodeSelector or affinity rules don't match
    • Node is in the wrong zone for the Pod's volume
  3. Scoring — it ranks the remaining nodes, for example preferring nodes with more free resources or spreading replicas across zones.
  4. Binding — it writes the chosen node name into the Pod.
  5. The kubelet on that node sees the Pod and starts the containers. (The scheduler itself never starts containers.)

Example

apiVersion: v1
kind: Pod
metadata:
  name: web
spec:
  nodeSelector:
    disktype: ssd          # only nodes labelled disktype=ssd pass filtering
  containers:
    - name: web
      image: nginx:1.27
      resources:
        requests:
          cpu: "500m"      # node must have 0.5 CPU free
          memory: "256Mi"

When a Pod is stuck in Pending, the scheduler tells you why:

kubectl describe pod web
# Events:
#   Warning  FailedScheduling  0/3 nodes are available:
#   1 Insufficient cpu, 2 node(s) didn't match Pod's node affinity/selector.

This message is gold in troubleshooting: it tells you exactly which filter rejected each node.

What to say in the interview

"The scheduler watches for Pods that don't have a node yet and assigns each one to a node. It works in two phases: filtering, which removes nodes that can't run the Pod because of resource requests, taints, node selectors or affinity rules; and scoring, which ranks the remaining nodes to pick the best one. It then binds the Pod to that node, and the kubelet on that node starts the containers. If no node fits, the Pod stays Pending, and kubectl describe pod shows the exact reason."

Follow-up questions you may get

  • Does the scheduler look at actual CPU usage? No — it uses resource requests, not live usage. That's why setting correct requests matters.
  • How do you force a Pod onto a specific node? nodeSelector or node affinity, combined with taints and tolerations to keep other Pods off that node.
  • How do you spread replicas across zones? Topology spread constraints or Pod anti-affinity.
All Kubernetes questions Roadmap: Kubernetes core

More on Architecture & Control Plane