Kubernetes: Introduction to Scheduling




In the last article we discussed about different types of services in Kubernetes. Now one of the most important thing to ponder upon is how scheduling of pods take place in kubernetes.





In the start of this series we have touched upon the fact that there are inbuilt schedulers that kubernetes already installs by default as a part of installation. Now what if you don't want to rely on these default schedulers and want to govern on your own , the scheduling part.


Here is where the concept of manual scheduling comes up. We have defined pod yaml file earlier but we never specified a field "nodeName" in to it because earlier we did not want any custom scheduling. We were OK with the way kubernetes schedule our pods on any random node.


Now let us discuss a different scenario. Currently we have three nodes in the cluster( node1,node2 and node3) . Suppose we have a requirement that a particular type of pod should always be launched on node 3 . This is how we can achieve this .


[root@node1 kubernetes]# cat nginx_pod_manual_schedule.yaml
apiVersion: v1
kind: Pod
metadata:
   name: nginx-pod-node3
   labels:
     app: myapp
spec:
   containers:
   - name: nginx-container
     image: nginx

   nodeName: node3.example.com
   
   ## Execute kubectl create -f nginx_pod_manual_schedule.yaml
   ## to create the pod. We will observe that the pod has been deployed 
   ## on node3.example.com 
   
   ###########################################################
   
   [root@node1 kubernetes]# kubectl describe pod nginx-pod-node3
Name:         nginx-pod-node3
Namespace:    default
Priority:     0
Node:         node3.example.com/192.168.1.13
Start Time:   Tue, 28 Jul 2020 15:14:13 +0530
Labels:       app=myapp
Annotations:  <none>
Status:       Running
IP:           10.244.1.38

What will happen is that , now the pod will always be deployed on node3. This is so easy right . That is it for this article , in the next articles we will explore more ways to schedule a pod








187 views0 comments

Recent Posts

See All