Pages

Tuesday, August 7, 2018

Control Plane Component - Scheduler

Share it Please
Now we have a component to save our data and another component which connects to the data server. Let's say that you are creating a Pod. You define a  pod definition file and you make a call to create the pod. Now the api server will take the call and save the pod details into etcd and create the pod. Now the question is where does this pod gets created?. How does k8 know where to create the pod?

This is done by the scheduler. The Job of the scheduler is to scan for unscheduled pods and then determines which is the best worker node to run the pod. 

How does this work?
Scheduler using the watch mechanism wait for newly created pods through the Api Server and assign a node to each new pod. The the scheduler identifies the correct node for hosting the pod and will update the API server with the details. The details of the node that the pod should run is updated in the etcd and kubectl on every node which is watching will get the details and kubectl will create the pod.

But how does scheduler identifies the node for hosting the pod?
Scheduler will run pre-defined functions to identify which node is suitable for hosting the pod. The functions can range from,
  1. Is this Node running out of resources
  2. Is the pod defined with this node for creation?
  3. Does the node have any label that matches the node selector defined in the pod definition.
  4. Do the pod needed port is available in here or not?
These are some of the functions that run and based on the results it identifies a suitable node for hosting the pod.

A default scheduler will run if none is specified. We can have a cluster with no scheduler specified which in turn lets us to do things manually.

No comments :

Post a Comment