This article explains how to deploy and configure multiple schedulers in a Kubernetes cluster alongside the default scheduler.
Welcome to this lesson on deploying multiple schedulers in a Kubernetes cluster. In this guide, you will learn how to deploy custom schedulers alongside the default scheduler, configure them correctly, and validate their operation.Kubernetes’ default scheduler distributes pods across nodes evenly while considering factors such as taints, tolerations, and node affinity. However, certain use cases may require a custom scheduling algorithm. For instance, when an application needs to perform extra verification before placing its components on specific nodes, a custom scheduler becomes essential. By writing your own scheduler, packaging it, and deploying it alongside the default scheduler, you can tailor pod placement to your specific needs.
Ensure that every additional scheduler has a unique name. The default scheduler is conventionally named “default-scheduler,” and any custom scheduler must be registered with its own distinct name in the configuration files.
Below are examples of configuration files for both the default and a custom scheduler. Each YAML file uses a profiles list to define the scheduler’s name.
In addition to running the scheduler as a service, you can deploy it as a pod inside the Kubernetes cluster. This method involves creating a pod definition that references the scheduler’s configuration file.
Leader election is an important configuration for high-availability environments. It ensures that while multiple scheduler instances are running, only one actively schedules the pods.
In many modern Kubernetes setups—especially those using kubeadm—control plane components run as pods or deployments. Below is an example of deploying a custom scheduler as a Deployment.
If the custom scheduler configuration is incorrect, the pod may remain in the Pending state. Conversely, a properly scheduled pod will transition to the Running state.
To confirm which scheduler assigned a pod, review the events in your namespace:
Copy
Ask AI
kubectl get events -o wide
A sample output might appear as follows:
Copy
Ask AI
LAST SEEN COUNT NAME KIND TYPE REASON SOURCE MESSAGE9s 1 nginx.15 Pod Normal Scheduled my-custom-scheduler Successfully assigned default/nginx to node018s 1 nginx.15 Pod Normal Pulling kubelet, node01 pulling image "nginx"2s 1 nginx.15 Pod Normal Pulled kubelet, node01 Successfully pulled image "nginx"2s 1 nginx.15 Pod Normal Created kubelet, node01 Created container2s 1 nginx.15 Pod Normal Started kubelet, node01 Started container
Notice that the event source is “my-custom-scheduler,” confirming that the pod was scheduled by your custom scheduler.If you encounter issues, view the scheduler logs with:
By following these techniques, you can run both the default Kubernetes scheduler and one or more custom schedulers concurrently. This flexibility allows you to assign specific workloads to the most appropriate scheduler based on your cluster’s requirements.Happy scheduling!