Best Overview of Custom Scheduler to Manage Highly Available Applications

Samuel Arogbonlo
Nerd For Tech
Published in
4 min readJul 15, 2021

--

TL:DR
Kubernetes has several tools used for managing applications but the custom scheduler is built to manage large applications with a robust cluster and user base. Majorly, it assigns pods to nodes when they are newly created and ensures the applications keep running without any downtime and all resources expectations are being handled.

Custom Scheduler Highlights
1. The scheduler is responsible for mapping persistent volumes to the pods in the cluster that has been previously scheduled.

2. Working with the scheduler, it has a plugin called Kube-scheduler which is a significant part of the control plane and the core of how the scheduler operates.

3. The main purpose of the scheduler is to assign pods to nodes with the highest rank and the plugins make this possible.

4. Custom Kubernetes Scheduler has open-source plugins and runs in all of Kubernetes CockroachCloud Clusters.

5. In running heavy traffic applications, custom Kubernetes scheduler can ensure the resources to be managed by the container are handled real-time so Kubernetes operations are optimized.

6. Custom Kubernetes Scheduler depends on some behaviours; policies and profiles as they help properly configure the functionalities of the scheduler.

By definition, the custom Kubernetes scheduler is designed to watch out for new pods in the system and ensures they are assigned to the best nodes that they could run on. Its operation is largely done by the plugin and its decision of nodes is influenced by the policies and profiles sectioned for the schedules.

The operation of the custom Kubernetes scheduler is successful with two major operations; Filtering and Scoring. While Filtering involves looking into the available nodes and confirming its ability to meet the requirements of the newly created pods to be scheduled, Scoring is the next step it takes and it involves assigning scores to each node that have resulted from the filtering process and then the pods will be assigned to the node with the highest scores. In the case that there is some form of ties in the scores between one or more nodes, then the winning node is selected at random.

Furthermore, the filtering and scoring functions of the scheduler are being configured based on policies and profiles which covers priorities for scoring and plugins configurations stages respectively. Some of those stages include Score, Bind, Filter and many others. Also, the scheduler performance can be tuned to suit the business needs especially for relatively large clusters and the scheduler’s behaviour strike a balance between latency and accuracy which involves how pods are quickly placed as well as ensuring the scheduler do not make poor decisions. Furthermore, while trying to test out the scheduler, there is documentation prepared to that effect.

Usage — A Step Further

Working with a custom scheduler, Kelsey Hightower has chunked up an interesting repo we could use to take a reference. You can look at the scheduler code in this repo here. Annotate each node using the annotator command:

kubectl proxyStarting to serve on 127.0.0.1:8001go run annotator/main.gogke-k0-default-pool-728d327f-00lq 1.60
gke-k0-default-pool-728d327f-3vzg 0.20
gke-k0-default-pool-728d327f-nmz7 0.80
gke-k0-default-pool-728d327f-pxee 0.05
gke-k0-default-pool-728d327f-xm4i 0.05
gke-k0-default-pool-728d327f-zynj 0.20

Create a deployment

kubectl create -f deployments/nginx.yamldeployment "nginx" created

The nginx pod should be in a pending state:

kubectl get podsNAME                     READY     STATUS    RESTARTS   AGE
nginx-1431970305-mwghf 0/1 Pending 0 27s

Run the Scheduler

List the nodes and note the price of each node.

annotator -lgke-k0-default-pool-728d327f-00lq 0.80
gke-k0-default-pool-728d327f-3vzg 0.40
gke-k0-default-pool-728d327f-nmz7 0.40
gke-k0-default-pool-728d327f-pxee 0.05
gke-k0-default-pool-728d327f-xm4i 1.60
gke-k0-default-pool-728d327f-zynj 0.40

Run the best price scheduler:

scheduler2016/08/19 11:16:25 Starting custom scheduler...
2016/08/19 11:16:28 Successfully assigned nginx-1431970305-mwghf to gke-k0-default-pool-728d327f-pxee
2016/08/19 11:16:35 Shutdown signal received, exiting...
2016/08/19 11:16:35 Stopped reconciliation loop.
2016/08/19 11:16:35 Stopped scheduler.

Notice the pending nginx pod is deployed to the node with the lowest cost.

Run the Scheduler on Kubernetes

kubectl create -f deployments/scheduler.yamldeployment "scheduler" created

Now, remember, many of these processes can be automated with CI/CD without hassles and any tool is proper for the job as long as your pipeline is built to orchestrate that process. At this point, any form of system change can roll out immediately. You can look up my preference for CI/CD here on this blog. Finally, you should have access to the original documentation and observe some extensive applications of the schedulers.

By way of conclusion, the custom Kubernetes scheduler is used to orchestrate and manage applications with high usage and ensures that there are no downtimes while the pods are rightly assigned and functional without any input from the developers except configuring the schedulers to operate on its own. Now, remember, this article is not only for experts in the software space, even newbies could hop in and learn a lot and that is why I try to make everything clear both in layman and professional terms, so if you have any questions, shoot or you can also reach out to me on Twitter or find me on GitHub.

Thanks for reading ❤️

Please leave a comment if you have any thoughts about the topic — I am open to learning and knowledge explorations.

I can imagine how helpful this post has been, do leave a clap 👏 below a few times to show your support for the author!

--

--

Samuel Arogbonlo
Nerd For Tech

A writer for Cloud and DevOps with a sprinkle of other interesting software concepts.