day4: kube scheduler
Source: Dev.to
Overview
The Kubernetes scheduler decides which node each pod should run on. It does not place the pods itself; instead, it records the target node for each pod. The Kubelet on the selected node is responsible for actually creating the pod.
Scheduler Phases
-
Filtering (Fit Phase)
The scheduler discards nodes that cannot host the pod, such as:- Nodes explicitly excluded by the pod’s specifications.
- Nodes lacking sufficient CPU, memory, or other resources required by the pod.
-
Scoring (Priority Phase)
The remaining nodes are scored using one or more priority functions (e.g., on a scale of 1–10). The pod is scheduled onto the node with the highest score.
Customization
- The scoring functions and their weights can be customized.
- You can implement a custom scheduler by writing your own scoring logic.
- Common determinants include:
- Resource requests and limits
- Taints and tolerations
- Node selectors
- Affinity/anti‑affinity rules
Installation
- Download the
kube-schedulerbinary from the Kubernetes release page. - Extract the binary and place it in a suitable directory (e.g.,
/usr/local/bin). - Run it as a service, specifying a scheduler configuration file (e.g.,
/etc/kubernetes/scheduler-config.yaml).
# Example: start kube-scheduler with a config file
kube-scheduler --config=/etc/kubernetes/scheduler-config.yaml
Viewing the Scheduler
- As a static pod: When deployed with
kubeadm, the scheduler runs as a pod in thekube-systemnamespace. Its manifest is located at/etc/kubernetes/manifests/kube-scheduler.yaml. - As a process: You can locate the running scheduler process with:
ps aux | grep kube-scheduler
Summary
The Kubernetes scheduler matches pods to the most suitable nodes based on filtering and scoring criteria. Its behavior can be tuned via built‑in policies or custom extensions, and it can be installed and inspected either as a static pod or a system service.