1
00:00:04,180 --> 00:00:07,150
Hello and welcome to this lecture in this lecture.

2
00:00:07,180 --> 00:00:10,000
we will talk about Kube Scheduler.

3
00:00:10,000 --> 00:00:15,540
Earlier we discussed that the kubernetes scheduler is responsible for scheduling pods on nodes.

4
00:00:16,300 --> 00:00:18,640
Now don't let the graphic mislead you.

5
00:00:18,670 --> 00:00:26,710
remember the scheduler is only responsible for deciding which pod goes on which node. It doesn’t actually

6
00:00:26,710 --> 00:00:29,010
place the pod on the nodes.

7
00:00:29,050 --> 00:00:34,690
That’s the job of the kubelet. The kubelet or the captain on the ship is who creates the pod on the

8
00:00:34,690 --> 00:00:35,610
ships.

9
00:00:35,610 --> 00:00:39,860
The scheduler only decides which pod goes where.

10
00:00:40,000 --> 00:00:43,270
Let's look at how the scheduler does that in a bit more detail.

11
00:00:43,420 --> 00:00:48,770
First of all why do you need a scheduler? When there are many ships and many containers,

12
00:00:48,940 --> 00:00:53,450
You want to make sure that the right container ends up on the right ship.

13
00:00:53,590 --> 00:00:57,670
For example there could be different sizes of ships and containers.

14
00:00:57,670 --> 00:01:04,130
You want to make sure the ship has sufficient capacity to accommodate those containers different ships

15
00:01:04,150 --> 00:01:06,280
maybe going to different destinations.

16
00:01:06,280 --> 00:01:11,740
You want to make sure your containers are placed on the right ships so they end up in the right destination

17
00:01:12,540 --> 00:01:17,170
In kubernetes, the scheduler decides which nodes the pods are placed on

18
00:01:17,170 --> 00:01:22,660
depending on certain criteria.  You may have PODs with different resource requirements,

19
00:01:22,720 --> 00:01:27,180
You can have nodes in the cluster dedicated to certain applications.

20
00:01:27,280 --> 00:01:33,700
So how does the scheduler assign these PODs? The scheduler looks at each POD and tries to find the

21
00:01:33,700 --> 00:01:35,280
best node for it.

22
00:01:35,290 --> 00:01:37,560
For example, let’s take one of these PODs.

23
00:01:37,810 --> 00:01:41,970
The big blue one. It has a set of CPU and Memory requirements.

24
00:01:42,040 --> 00:01:47,980
The scheduler goes through two phases to identify the best node for the pod in the first phase.

25
00:01:48,010 --> 00:01:52,940
The scheduler tries to filter out the nodes that do not fit the profile for this pod.

26
00:01:53,050 --> 00:01:59,830
For example, the nodes that do not have sufficient CPU and memory resources requested by the pod.

27
00:01:59,860 --> 00:02:06,100
So the first two small nodes are filtered out.  So we are now left with two nodes on which the POD

28
00:02:06,130 --> 00:02:07,870
can be placed.

29
00:02:07,900 --> 00:02:14,660
Now how does the scheduler pick one from the two the scheduler ranks the node to identify the best fit

30
00:02:14,660 --> 00:02:15,580
for the pod.

31
00:02:15,620 --> 00:02:21,240
It uses a priority function to assign a score to the nodes on a scale of 0 to 10.

32
00:02:21,260 --> 00:02:28,130
For example the scheduler calculates the amount of resources that would be free on the nodes after placing

33
00:02:28,130 --> 00:02:29,570
the pod on them.

34
00:02:29,570 --> 00:02:36,230
In this case, the one on the right would have 6 CPUs free  if the pod was placed on it which is 4 more

35
00:02:36,560 --> 00:02:39,430
than the other one so it gets a better rank.

36
00:02:39,530 --> 00:02:40,820
And so it wins.

37
00:02:40,910 --> 00:02:43,220
So that's how a scheduler works at a high level.

38
00:02:43,280 --> 00:02:48,380
And of course these can be customized and you can write your own scheduler as well.

39
00:02:48,380 --> 00:02:53,660
There are many more topics to look at such as resource requirements, limits, taints and tolerations,

40
00:02:53,690 --> 00:03:00,290
node selectors, affinity rules etc. Which is why we have an entire section dedicated to scheduling coming

41
00:03:00,290 --> 00:03:04,940
up in this course where we will discuss each of these in much more detail.

42
00:03:04,940 --> 00:03:10,040
For now we will continue to focus on the scheduler as a process at a high level.

43
00:03:10,760 --> 00:03:13,160
So how do you install the kube-scheduler?

44
00:03:13,160 --> 00:03:18,740
Download the kube-scheduler from the kubernetes release page. Extract it and run it as a service.

45
00:03:19,220 --> 00:03:20,600
when you run it as a service.

46
00:03:20,600 --> 00:03:23,090
You specify the scheduler configuration file.

47
00:03:23,570 --> 00:03:26,240
So how do you view the kube-scheduler server options?

48
00:03:26,240 --> 00:03:31,820
Again, if you set it up with kubeadm tool, kubeadm deploys the kube-scheduler as a pod

49
00:03:31,820 --> 00:03:33,450
in the kube-system namespace

50
00:03:33,470 --> 00:03:39,030
on the master node. You can see the options within the pod definition file located at etc

51
00:03:39,090 --> 00:03:41,270
kubernetes manifests folder.

52
00:03:41,420 --> 00:03:46,280
You can also see the running process and the effective options by listing the process on the master

53
00:03:46,280 --> 00:03:49,250
node and searching for kube-scheduler.

54
00:03:49,250 --> 00:03:51,020
Well that's it for this lecture.

55
00:03:51,200 --> 00:03:52,550
I will see you in the next.
