1
00:00:00,580 --> 00:00:06,640
Hello and welcome to this lecture. In this lecture we look at the different ways of manually scheduling

2
00:00:06,670 --> 00:00:13,700
a POD on a node. What do you do when you do not have a scheduler in your cluster?

3
00:00:13,700 --> 00:00:20,950
You, probably do not want to rely on the built in scheduler and instead want to schedule the PODs yourself.

4
00:00:21,020 --> 00:00:23,780
So how exactly does a scheduler work in the backend.

5
00:00:24,440 --> 00:00:27,230
Let's start with a simple pod definition file.

6
00:00:27,560 --> 00:00:33,860
Every POD has a field called NodeName that, by default, is not set.

7
00:00:33,860 --> 00:00:41,600
You don’t typically specify this field when you create the manifest file, Kubernetes adds it automtically.

8
00:00:41,600 --> 00:00:48,560
The scheduler goes through all the pods and looks for those that do not have this property set.

9
00:00:48,560 --> 00:00:51,460
Those are the candidates for scheduling.

10
00:00:51,530 --> 00:00:57,020
It then identifies the right node for the POD, by running the scheduling algorithm.

11
00:00:57,020 --> 00:01:03,680
Once identified it schedules the POD on the Node by setting the node Name property to the name of the

12
00:01:03,680 --> 00:01:12,240
node by creating a binding object. So if there is no scheduler to monitor and schedule nodes what happens?

13
00:01:12,330 --> 00:01:15,780
The pods continue to be in a pending state.

14
00:01:15,780 --> 00:01:17,270
So what can you do about it.

15
00:01:17,280 --> 00:01:23,340
You can manually assign pods to node yourself. Well without a scheduler,

16
00:01:23,340 --> 00:01:29,640
the easiest way to schedule a pod is to simply set the node name field to the name of the node in your

17
00:01:29,640 --> 00:01:33,540
pod specification while creating the POD.

18
00:01:33,540 --> 00:01:40,610
The pod then gets assigned to the specified node. You can only specify the node name at creation time.

19
00:01:40,710 --> 00:01:46,500
What if the pod is already created and you want to assign the pod to a node? Kubernetes won’t allow

20
00:01:46,500 --> 00:01:50,220
you to modify the node Name property of a pod.

21
00:01:50,370 --> 00:01:57,960
So another way to assign a note to an existing pod is to create a binding object and send a post request

22
00:01:57,960 --> 00:02:05,910
to the pod binding API thus mimicking what the actual scheduler does. In the binding object you specify

23
00:02:06,000 --> 00:02:13,740
a target node with the name of the node. Then send a post request to the pods binding API with the data

24
00:02:13,830 --> 00:02:17,580
set to the binding object in a JSON format.

25
00:02:17,580 --> 00:02:22,850
So you must convert the YAML file into its equivalent JSON format.

26
00:02:22,920 --> 00:02:24,960
Well that's it for this lecture.

27
00:02:24,960 --> 00:02:30,300
Head over to the practice test and practice manually scheduling pods on nodes.
