The k8s scheduler, controls how Pods are scheduled onto k8s worker nodes, based on various factors like node affinity, the container operational requirements (CPU, Memory), etc. This component is part of the k8s control plane.
Important
The scheduler only “schedules” — it doesn’t initiate the pods onto the nodes; this is the job of the kubelet. It only communicates its decisions to the kube-apiserver which then prompts the respective kublet/s to realise the changes.
Scheduling phases
The scheduler goes through 2 stages when choosing a suitable node for a pod:
- Filtering
- The scheduler marks any node that matches the most basic requirements of a Pod (resource requests) feasible. If none of the nodes are suitable, the pod remains unscheduled.
- Scoring
- The SCHED ranks the filtered feasible nodes, based on the active scoring criteria1. The node with the highest score is selected2.
Note
These two stages are referred to as scheduling. Factors in making a decision include hardware/software constraints, node affinity, etc.
Then, the SCHED shares its decision with the kube-apiserver, in a process called binding. Finally, the Pod is assigned to a Node.
Sources
Footnotes
-
The filtering and scoring behaviour can be modified through scheduling policies. You could even introduce additional stages into the cycle through various plugins that can be configured via scheduling profiles. ↩
-
If Nodes have equivalent score, one is selected at random. ↩