Lab14 - Kubernetes Scheduler
Lab14 - Kubernetes Scheduler
Introduction
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. The scheduler reaches this placement decision taking into account the scheduling
principles described below.
kube-scheduler is the default scheduler for Kubernetes and runs as part of the control plane.
kube-scheduler is designed so that, if you want and need to, you can write your own scheduling
component and use that instead.
In this Lab, you will learn below items:
Objective:
1.1 Let us clone the git repository which contains manifests required for this exercise, by executing the
below command.
Output:
1.3 Let us view the manifest for pod which can assign pod to the node manually, by executing the below
command.
# cat -n ~/k8s-scheduler/manual-pod.yaml
Output:
Specifying the field nodeName, we can direct Kubernetes where to deploy the Pod, bypassing the kube-
scheduler
1.7 Let us edit the manifest to run the pod on kube-node2, by executing the below command.
1.8 Let us view the manifest for pod, by executing the below command.
# cat -n ~/k8s-scheduler/manual-pod.yaml
Output:
2 Let us view the labels of the nodes in our cluster, by executing the below command.
2.1 Let us add a label to the kube-node1, by executing the below command.
2.4 Let us view the manifest for pod, by executing the below command.
# cat -n ~/k8s-scheduler/manual-pod-disktype.yaml
Output:
2.6 Let us verify the pod details, by executing the below command.
Note: Pod will get scheduled on the node that you attached the label
2.7 Let us remove labels from the node, by executing the below command.
In this section let us see, how the PODs are distributed among the nodes when no nodeSelector is set
on the PODs. We expect a more or less even distribution of the PODs among the nodes.
3.1 Let us view the manifest of the pod, by executing the below command.
# cat -n ~/k8s-scheduler/default-scheduler.yaml
Output:
3.3 Let us verify the details of the pods, by executing the below command.
# cat -n ~/k8s-scheduler/node-selector.yaml
Output:
3.7 Let us view the details of the pods, by executing the below command.
3.8 We can see that the PODs are in pending status since the scheduler has not yet found any matching
node. Let us look more closely:
3.10 Let us verify the status of the pods, by executing the below command.
3.11 Let us now remove the Label from the kube-master node, by executing the below command.
Output:
3.12 After removing the lable for master let us verify the pod details, by executing the below
command.
Note: We see that the nodeSelector is applied during Scheduling only: running PODs are still running on
the node, even if the label is removed from the node, it will not affect the already running pods.
Output:
# cat -n ~/k8s-scheduler/node-selector-vip.yaml
Output: