Score:2

Why is the Kubernetes scheduler a separate process from the controller manager?

br flag

This is a question about the design of Kubernetes, I don't have a specific technical problem to solve, but I'm trying to understand the thoughts behind some of its architecture.

All explanations about Kubernetes' control plane that I've seen mention that it consists of:

  • a controller manager
  • a scheduler

(among other components, but they're not important for the question)

From what I understand, the controller manager is a helper process which groups multiple controllers together for performance reasons. It watches the API server and has some state machine, the shared informer, which effectively allows many controllers to share a relatively expensive watch of the API server and be guaranteed some form of consistency since they all run in the same operating system process.

If I understand correctly, the scheduler itself is also a controller, whose goal is to assign a nodeName to pods so that they will be picked up and run by the kubelets.

Now, what I have not been able to find out is why the scheduler is run as a separate process. Would it be possible to make a scheduler that runs as part of the controller manager? If so, what is the reason for not making it part of the latter by default?

Score:0
dk flag

As per this official doc, the Kubernetes cluster is managed by the Kubernetes master, who also runs the API Server, Controller Manager, Scheduler, and etcd components.

Any machine in the cluster can run control plane components. Setup scripts, on the other hand, typically run user containers but do not start all control plane components on the same machine for simplicity's sake. For an example of a control plane setup that runs on multiple machines, see Kubernetes Components Using kubeadm to create highly available clusters.

kube-scheduler

Control plane component that watches for newly created Pods with no assigned node, and selects a node for them to run on. Factors taken into account for scheduling decisions include: individual and collective resource requirements, hardware/software/policyconstraints, affinity and anti-affinity specifications, data locality, inter-workload interference, and deadlines.

kube-controller-manager

Control plane component that runs controller processes.

Logically, each controller is a separate process, but to reduce complexity, they are all compiled into a single binary and run in a single process.

Some types of these controllers are:

  1. Node controller: Responsible for noticing and responding when nodes go down.

  2. Job controller: Watches for Job objects that represent one-off tasks, then creates Pods to run those tasks to completion.

  3. EndpointSlice controller: Populates EndpointSlice objects (to provide a link between Services and Pods).

  4. ServiceAccount controller: Create default ServiceAccounts for new namespaces.

Control manager is responsible for noticing and responding when nodes go down whereas scheduler watches for newly created Pods that have no Node assigned. For every Pod that the scheduler discovers, the scheduler becomes responsible for finding the best Node for that Pod to run on.

so,Kubernetes scheduler is separate process from the controller manager and Refer this doc for more information written by Jorge Acetozi

Jakob Odersky avatar
br flag
Thanks for the links, but they don't really answer the question. I understand that there is a scheduler and a kube-controller-manager and what they do, but what I'm looking for is the idea behind *why* the scheduler is treated as a separate component even though it's also a controller.
Sai Chandini Routhu avatar
dk flag
As you are aware the Controller manager maintains control loop and encompasses multiple controllers and runs as a single process and its core fucntionality is to monitor the state of cluster. If the controller manager has been made to not only monitor the state but also enforce which pods should run on which node similar to Scheduler, it will not only increases complexity of its already complicated design, but also from deviate from loosely packed architecture.
Sai Chandini Routhu avatar
dk flag
As per my understanding even Kubernetes follows Microservices architecture and hence it has been made up of well defined but loosely coupled components. If we observe the other core components such as etcd, API server it has uniquely defined functionality and responsibilties of Kube Scheduler and Kube controller manager also been stipulated in the similar fashion. Hope this will answer your queries
Score:0
tk flag

The Scheduler and Controller Manager are separate components and they have distinct responsibilities and requirements.

they are kept separate for some reasons:

1- Decoupling of responsibilities: having different responsibilities makes them should not be tightly coupled. The Scheduler is responsible for scheduling workloads, while the Controller Manager is responsible for managing various controllers that ensure the desired state of the cluster is maintained. By keeping these responsibilities separate, it is easier to maintain and upgrade each component independently.

Scalability: The Scheduler needs to be able to schedule workloads efficiently and quickly, while the Controller Manager needs to be able to manage a large number of controllers

Flexibility: keeping the Scheduler and Controller Manager separate allows for more flexibility in designing and implementing new features.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.