Learn to deploy multiple schedulers in Kubernetes, including identifying the default scheduler and creating a custom scheduler configuration.
In this lesson, you will learn how to deploy multiple schedulers in Kubernetes. We will go through the steps to identify the default scheduler, create and deploy a custom scheduler configuration, and finally run a pod using the new scheduler.
Begin by inspecting the cluster’s pods to identify the default Kubernetes scheduler pod. In most installations, the pod name is similar to kube-scheduler-controlplane. Use the following command to list all pods across namespaces:
2. Verify Service Account and Cluster Role Binding
Before deploying the custom scheduler, ensure that the service account and cluster role binding required for it are in place. Verify the service account with the following commands:
Copy
Ask AI
root@controlplane ~ ⊢ kubectl get sa my-schedulerError from server (NotFound): serviceaccounts "my-scheduler" not foundroot@controlplane ~ ⊢ kubectl get sa my-scheduler -n kube-systemNAME SECRETS AGEmy-scheduler 1 26s
Since the necessary resources exist, you can proceed to the next step.
Deploy the custom scheduler using a manifest file (e.g., /root/my-scheduler.yaml). The manifest below deploys a custom scheduler pod using the same image as the default scheduler. Replace <use-correct-image> with k8s.gcr.io/kube-scheduler:v1.23.0 as shown:
The final step involves creating a pod that explicitly uses the newly deployed custom scheduler. Below is an example manifest for an nginx pod. Notice that we specify schedulerName: my-scheduler to bind the pod to the custom scheduler:
Save this manifest to a file named nginx-pod.yaml, then create the pod:
Copy
Ask AI
root@controlplane ~ # kubectl create -f nginx-pod.yamlpod/nginx created
Confirm that the pod is running as expected in the default namespace (or your desired namespace):
Copy
Ask AI
root@controlplane ~ # kubectl get podsNAME READY STATUS RESTARTS AGEnginx 1/1 Running 0 4s
This completes the lab for deploying a custom scheduler in Kubernetes and scheduling a pod using that scheduler.For more detailed information on Kubernetes scheduling, please check out the Kubernetes Documentation.