CloudPe
Glossary

kube-scheduler in Kubernetes

CloudPe Team
kube-scheduler in Kubernetes

What is a kube-scheduler in Kubernetes

kube-scheduler is the control plane component that decides which node a pod should run on. When you create a pod, it doesn’t start running anywhere right away. kube-scheduler watches for pods with no node assigned, picks the best available node, and assigns it there.
You never call kube-scheduler directly. It works quietly in the background every time a pod is created.

How kube-scheduler picks a node

For every unscheduled pod, kube-scheduler runs through two steps:

  • Filtering: Removes nodes that can’t run the pod, for example, nodes without enough CPU or memory, or nodes that don’t match a required label.
  • Scoring: Ranks the remaining nodes and picks the best fit, based on factors like resource availability, affinity/anti-affinity rules, and how spread out your pods already are.

The pod gets assigned to the highest-scoring node. Then the kubelet on that node takes over and actually runs it.

A simple example

Say you deploy a pod that needs 2 CPU cores. kube-scheduler checks every node, filters out any node with less than 2 CPU cores free, then scores the rest, and assigns the pod to the node that fits best without overloading it.
You can influence this with rules in your pod spec:

apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
nodeSelector:
disktype: ssd
containers:
- name: my-app
image: my-app:1.0
resources:
requests:
cpu: "2"

Here, nodeSelector tells kube-scheduler to only consider nodes labeled disktype: ssd.

Checking scheduler activity

kube-scheduler runs as a static pod in the kube-system namespace, similar to kube-apiserver.

#Check if kube-scheduler is running

kubectl get pods -n kube-system | grep kube-scheduler

View its logs

kubectl logs kube-scheduler- -n kube-system

Check scheduler metrics (if metrics endpoint is exposed)

kubectl get –raw /metrics | grep scheduler

Scheduler metrics are useful for spotting scheduling delays or pods stuck in a Pending state, usually a sign that no node currently fits the pod’s requirements.

Where it fits in the control plane

kube-scheduler works alongside kube-apiserver and etcd. It watches the API server for unscheduled pods, makes its decision, and writes that decision back through the API server, which then updates etcd.

For deeper implementation details or to experiment with scheduling logic, the kube-scheduler source code is part of the main Kubernetes GitHub repository.