WEBVTT

00:00.590 --> 00:02.340
Hello and welcome to this lecture.

00:03.150 --> 00:05.850
Now that we have learned
about taints and tolerations,

00:06.020 --> 00:07.390
and node affinity,

00:07.760 --> 00:11.940
let us tie together the two concepts
through a fun exercise.

00:12.630 --> 00:16.610
We have three nodes and three pods
each in three colors,

00:17.070 --> 00:18.440
blue, red and green.

00:19.200 --> 00:22.870
The ultimate aim is to place
the blue pod in the blue node,

00:23.290 --> 00:26.320
the red pod in the red node
and likewise for green.

00:27.200 --> 00:29.690
We are sharing
the same Kubernetes cluster

00:29.860 --> 00:30.960
with other teams.

00:31.210 --> 00:34.740
There are other pods in the cluster
as well as other nodes.

00:35.340 --> 00:39.380
We do not want any other pod
to be placed on our node.

00:39.970 --> 00:44.110
Neither do we want our pods
to be placed on their nodes.

00:44.990 --> 00:47.390
Let us first
try to solve this problem

00:47.570 --> 00:49.480
using taints and tolerations.

00:50.140 --> 00:54.560
We apply a taint to the nodes,
marking them with their colors,

00:54.990 --> 00:56.580
blue, red, and green.

00:57.560 --> 01:02.350
We then set a toleration on the pods
to tolerate the respective colors.

01:03.440 --> 01:05.200
When the pods are now created,

01:05.550 --> 01:06.990
the nodes ensure

01:07.190 --> 01:10.720
they only accept the pods
with the right toleration.

01:11.210 --> 01:13.380
The green pod ends up
on the green node,

01:13.610 --> 01:16.050
and the blue pod ends up
on the blue node.

01:16.340 --> 01:17.340
However,

01:17.510 --> 01:20.010
taints and tolerations
does not guarantee

01:20.180 --> 01:22.850
that the pods
will only prefer these nodes,

01:23.130 --> 01:26.080
so the red node ends up
on one of the other nodes

01:26.250 --> 01:29.210
that do not have
a taint or toleration set.

01:30.010 --> 01:31.370
This is not desired.

01:32.420 --> 01:35.860
Let us try to solve the same problem
with node affinity.

01:36.300 --> 01:37.380
With node affinity,

01:37.730 --> 01:40.920
we first label the nodes
with their respective colors,

01:41.380 --> 01:42.650
blue, red and green.

01:43.030 --> 01:45.810
We then set
node selectors on the pods

01:45.980 --> 01:47.770
to tie the pods to the nodes.

01:48.170 --> 01:51.430
As such,
the pods end up on the right nodes.

01:51.800 --> 01:54.360
However, that does not guarantee

01:54.670 --> 01:57.720
that other pods
are not placed on these nodes.

01:57.890 --> 01:58.890
In this case,

01:59.060 --> 02:00.060
there is a chance

02:00.290 --> 02:03.700
that one of the other pods
may end up on our nodes.

02:04.280 --> 02:06.210
This is not something we desire.

02:06.600 --> 02:07.600
As such,

02:07.770 --> 02:10.170
a combination
of taints and tolerations

02:10.340 --> 02:11.880
and node affinity rules

02:12.050 --> 02:13.050
can be used together

02:13.220 --> 02:16.540
to completely dedicate nodes
for specific parts.

02:17.930 --> 02:20.030
We first use taints and tolerations

02:20.190 --> 02:23.060
to prevent other pods
from being placed on our nodes.

02:23.730 --> 02:25.710
Then we use node affinity

02:25.870 --> 02:29.050
to prevent our pods
from being placed on their nodes.

02:30.010 --> 02:32.060
Well, that's it for this lecture.

02:32.440 --> 02:34.150
Head over to the coding exercises

02:34.320 --> 02:36.720
and play around
with taints, tolerations

02:36.890 --> 02:37.890
and node affinity.

