# Scheduler In this section we will configure scheduler. ![image](./img/07_cluster_architecture_scheduler.png "Kubelet") > In Kubernetes, a scheduler is a core component responsible for assigning and placing workloads (such as pods) onto available nodes in a cluster. It ensures that the cluster's resources are utilized efficiently and that workloads are scheduled based on their resource requirements and other constraints. > Kublet, regularly request the list of pods assigned to it. In case if new pod appear, kubelet will run new pod. In case if pod marked as deleted, kubelet will start termination process. In previous section, we created pod and it was runed on the node, but why? The reason of that, we specified the node name on which to run the pod by our self ```bash nodeName: ${HOST_NAME} ``` So, lets create pod without node specified ```bash { cat < pod.yaml apiVersion: v1 kind: Pod metadata: name: hello-world spec: serviceAccountName: hello-world containers: - name: hello-world-container image: busybox command: ['sh', '-c', 'while true; do echo "Hello, World!"; sleep 1; done'] EOF kubectl apply -f pod.yaml } ``` And check pod status ```bash kubectl get pod -o wide ``` Output: ``` NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES hello-world 0/1 Pending 0 19s ``` As we can see node field of our pod is none and pod is in pending state. So, lets, configure scheduler and check if it will solve the issue. ## certificates We will start with certificates. As you remeber we configured our API server cto use client certificate to authenticate user. So, lets create proper certificate for the scheduler ```bash { cat > kube-scheduler-csr.json < ``` As you can see, our pod still in pending mode. To define the reason of this, we will review the logs of our scheduler. ```bash ... May 21 20:52:25 example-server kube-scheduler[91664]: I0521 20:52:25.471604 91664 factory.go:338] "Unable to schedule pod; no fit; waiting" pod="default/hello-world" err="0/1 nodes are available: 1 node(s) had taint {node.kubernetes.io/not-ready: }, that the pod didn't tolerate." ... ``` As we can see our pod wasn't assigned to the node because node has some taint, lets check our node taints. ```bash kubectl get nodes $(hostname -a) -o jsonpath='{.spec.taints}' ``` Output: ``` [{"effect":"NoSchedule","key":"node.kubernetes.io/not-ready"}] ``` As you can see, our node has taint with efect no schedule. The reason of this???? But lets fix this. ```bash kubectl taint nodes $(hostname -a) node.kubernetes.io/not-ready:NoSchedule- ``` And check our pods list again ```bash kubectl get pod -o wide ``` Output: ``` NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES hello-world 1/1 Running 0 29m 10.240.1.3 example-server ``` As you can see out pod is in running state, means that scheduler works as expected. Now we need to clean-up our wirkspace ```bash kubectl delete -f pod.yaml ``` Next: [Controller manager](./08-controller-manager.md )