Kubernetes: Scheduler

Claire Lee
3 min readMar 12, 2023

--

The Kubernetes scheduler assigns pods to nodes based on Pod’s scheduling requirements. The scheduler is responsible for identifying newly created pods and scheduling them to run on a specific node. It does this by first filtering out unsuitable nodes and then scoring feasible nodes. Finally, it selects the node with the highest score to bind the pod.

Kubernetes: Scheduler

Scheduler

The Kubernetes scheduler is a vital component of the Kubernetes control plane that allocates pods to nodes in a cluster based on available resources, node constraints, and user-defined criteria. It ensures optimal resource utilization and efficient application performance by selecting the most suitable node for each pod. Additionally, the scheduler continuously monitors the cluster and automatically reschedules pods in response to changes in resource availability, node constraints, or other conditions. This dynamic resource allocation and management capability ensure high availability and fault tolerance in a Kubernetes cluster, enabling applications to run smoothly and reliably.

In a restaurant, the timetable represents the Kubernetes scheduler, the dishes represent pods in Kubernetes, and the chefs represent nodes in the cluster. The timetable looks at all the dishes that need to be prepared and assigns them to specific chefs based on their expertise and workload. It ensures that each dish is prepared by the right chef at the right time.

How Does Scheduler Work?

How Scheduler works

1. Identify Unscheduled Pods

Identify newly created pods. When a new Pod is created in Kubernetes, it is initially in the “Pendingstate, meaning that it has not yet been scheduled to run on a specific node in the cluster.

2. Select an optimal node

2.1 Filtering
Filter out
nodes that do not meet the criteria for scheduling the pod. The criteria may include resource requests and limits, node selectors, taints, and tolerations.

2.2 Scoring
Score
the remaining feasible nodes based on factors such as resource availability, location, and affinity/anti-affinity preferences. This scoring process helps the scheduler make an optimal decision in selecting the best-suited node for the pod.

3. Binding

Choose the node with the highest score among the feasible ones and bind the pod to that node. It updates the Pod’s specification to include the name of the selected node, and the Pod transitions from the “Pending” state to the “Running state. If the scheduler is unable to find a suitable node for the Pod, the Pod will remain in the “Pending” state until a suitable node becomes available.

--

--