WEBVTT

00:00.633 --> 00:06.273
Okay, so let's go over the lab
for practicing taints and tolerations.

00:07.926 --> 00:09.513
Let's start with the first question.

00:09.593 --> 00:13.593
How many nodes exist on the system,
including the control plane?

00:13.673 --> 00:16.213
Let's look at the number of nodes

00:16.980 --> 00:19.846
and we see that there are 2 nodes
control plane and node01,

00:19.926 --> 00:21.560
the answer is 2.

00:27.953 --> 00:33.013
The next question is,
do any taints exist on node01 node?

00:34.406 --> 00:37.380
For that, we're going to have
to take a closer look at node01.

00:37.460 --> 00:42.460
We do kubectl describe node01

00:44.660 --> 00:46.380
and we see

00:49.500 --> 00:50.633
taints right here

00:50.986 --> 00:52.446
and we see that there are none.

00:52.526 --> 00:56.113
There are no taints
on this particular node.

00:56.220 --> 00:57.320
I'm going to select, no.

01:02.286 --> 01:03.886
It's going to clear my screen.

01:05.166 --> 01:08.906
The next question is
to create a taint on node01

01:09.406 --> 01:14.626
with key of spray value of mortein
and effect of NoSchedule.

01:15.226 --> 01:18.300
We're going to continue
with the silly example

01:18.700 --> 01:20.226
that we used in the lecture

01:20.473 --> 01:24.780
of the spray and mortein
and mosquito and B.

01:26.346 --> 01:28.600
Here, the task is to create a taint.

01:28.686 --> 01:31.766
We're going to do kubectl taint,

01:31.986 --> 01:34.713
and let's quickly look at the help.

01:36.593 --> 01:39.893
The command is kubectl taint
and then nodes,

01:40.726 --> 01:41.966
then the name of the node,

01:42.553 --> 01:48.820
and then followed by these values,
which are the key has to be spray.

01:49.066 --> 01:53.613
Then the value is mortein
and then the effect is NoSchedule.

01:54.593 --> 01:55.613
Let's do that.

01:55.873 --> 02:01.940
It's kubectl taint node.

02:03.640 --> 02:05.726
It's node01.

02:08.586 --> 02:13.673
Then the key is spray

02:15.133 --> 02:18.526
and the value is mortein

02:19.806 --> 02:24.833
and the effect is NoSchedule.

02:26.460 --> 02:27.460
Okay.

02:28.846 --> 02:30.680
Let's confirm that.

02:36.633 --> 02:41.226
We have the spray=mortein
and NoSchedule effect,

02:41.546 --> 02:43.906
so that's done.

02:46.406 --> 02:49.246
We now have a taint on node01.

02:49.993 --> 02:53.220
Now the goal is to create a new pod
with the nginx image

02:53.300 --> 02:56.573
and the pod name as mosquito.

02:57.313 --> 02:59.840
We're going to do a kubectl run,

03:04.206 --> 03:08.226
that's the pod name image=nginx.

03:10.073 --> 03:14.820
Let's do get pods.

03:15.080 --> 03:21.120
Let me see that it's created,
ignore the status for now.

03:26.153 --> 03:28.346
Okay, so what is
the state of the pod?

03:30.193 --> 03:32.346
It seems to be in a pending state.

03:32.553 --> 03:33.900
Select pending.

03:37.626 --> 03:40.340
Now, why do you think
the pod is in a pending state?

03:42.170 --> 03:44.680
Is it because the image
is not available, is there an error?

03:44.760 --> 03:45.760
Let's see.

03:45.993 --> 03:49.993
Let's do describe pod

03:52.473 --> 03:53.473
and the pod name

03:54.520 --> 03:55.986
and here, you'll see

04:00.400 --> 04:02.506
the reason why
it's in a pending state.

04:02.586 --> 04:06.113
It says that
the pod didn't tolerate 1 node

04:06.666 --> 04:12.006
that had taint, spray, and mortein
that the pod didn't tolerate.

04:12.410 --> 04:17.846
Basically, the pod mosquito
cannot tolerate the taint mortein,

04:18.666 --> 04:19.720
that's a problem here.

04:20.400 --> 04:21.533
We're going to select that.

04:27.406 --> 04:30.160
Okay, so now we have to create
another pod named bee

04:30.466 --> 04:31.526
with the nginx image,

04:31.666 --> 04:34.886
which has a toleration
set to the taint mortein.

04:35.300 --> 04:40.820
We're going to do a kubectl
run command to create a pod.

04:41.553 --> 04:43.206
The name is going to be bee

04:43.786 --> 04:46.893
and the image is going to be nginx.

04:49.800 --> 04:53.133
Basically, now we have to add
toleration to it,

04:53.233 --> 04:56.360
but you cannot specify toleration
in the command line.

04:56.440 --> 05:01.673
What we're going to do is
we are going to do a dry run= client

05:01.753 --> 05:06.440
to generate a yaml file
with this pod.

05:07.153 --> 05:08.493
That's the yaml file,

05:08.573 --> 05:11.706
and we're going to redirect that
to bee.yaml.

05:14.086 --> 05:19.373
We have this in bee.yaml,
we're going to edit bee.yaml file,

05:20.260 --> 05:24.920
and we're going to add in tolerations.

05:26.446 --> 05:28.926
Add a section called tolerations.

05:30.086 --> 05:32.720
Now if you're not sure of the format,

05:33.180 --> 05:35.140
check out the Kubernetes
documentation pages

05:35.220 --> 05:38.733
and search for taints
and tolerations.

05:40.126 --> 05:41.933
That's the first result.

05:45.053 --> 05:46.493
This is the command taint

05:47.340 --> 05:49.493
and this is the format
for tolerations

05:50.120 --> 05:53.173
so dash key, operator,
value, and effect.

05:55.080 --> 05:59.613
That's key,
so key is going to be spray,

06:01.460 --> 06:04.406
operator, value, and effect.

06:04.486 --> 06:09.766
The value is going to be mortein,

06:11.306 --> 06:16.173
effect is going to be NoSchedule.

06:17.713 --> 06:20.546
Finally, we have operator
which has to be equal.

06:22.986 --> 06:24.680
Operator set to equal,

06:26.766 --> 06:27.766
you save that,

06:31.100 --> 06:35.100
and let's create image.

06:41.480 --> 06:44.973
Okay, it's now
in a container-creating state.

06:45.673 --> 06:48.766
Let's watch the creation process

06:48.846 --> 06:51.540
and we can see that
it's now in a running state.

06:54.033 --> 06:55.493
This part is now running.

06:59.900 --> 07:01.600
Okay, so that's correct.

07:02.153 --> 07:04.913
Notice the bee pod
was scheduled on node01.

07:04.993 --> 07:09.626
Let's see where it was scheduled.

07:11.060 --> 07:14.500
We see the bee pod is on node01.

07:15.220 --> 07:21.713
Basically, now this bee was able
to tolerate the taint set on node01.

07:23.913 --> 07:27.113
Do you see any taints
on controlplane node?

07:27.193 --> 07:31.273
Let's look at the controlplane node.

07:35.740 --> 07:37.073
Let's look at taints

07:37.153 --> 07:41.786
and we see that yes, there is a taint
set on the controlplane node

07:43.126 --> 07:44.833
and it's set to NoSchedule.

07:44.913 --> 07:45.913
That's the effect.

07:46.540 --> 07:49.713
Yes, it's set
and it's set to NoSchedule.

07:54.473 --> 07:56.606
Okay, now remove the taint
on controlplane,

07:56.973 --> 07:59.426
which currently has
the taint effect of NoSchedule.

08:00.493 --> 08:01.813
We've got to remove that.

08:03.020 --> 08:05.113
First, let's get that.

08:09.613 --> 08:11.586
This is the taint.

08:12.233 --> 08:13.233
Let's copy that.

08:14.220 --> 08:17.106
The command to remove
is the same, kubectl taint.

08:18.053 --> 08:22.393
You just specify the node,
that's controlplane node.

08:22.846 --> 08:25.540
Specify the taint
that we want to remove

08:25.620 --> 08:28.973
and at the end,
you've got to put a dash or a minus

08:30.200 --> 08:32.080
or to remove that taint.

08:32.160 --> 08:33.540
It says it's untainted.

08:33.686 --> 08:36.746
Let's confirm that.

08:37.500 --> 08:39.906
Go back to taint.

08:39.986 --> 08:42.780
I see that nothing is set.

08:43.886 --> 08:44.886
Let's click on check.

08:51.646 --> 08:53.760
Okay, so that's done.

08:54.620 --> 08:56.360
Now we've got to check

08:56.440 --> 09:01.753
the status of the pods again.

09:02.286 --> 09:06.606
We see that the pod mosquito
which earlier was in a pending state

09:06.686 --> 09:08.126
is now in a running state.

09:08.893 --> 09:11.480
That's the state of the pod mosquito.

09:12.766 --> 09:14.766
Then we have to,

09:16.220 --> 09:20.220
let's check
on what node it is placed.

09:20.300 --> 09:23.573
As you can see, it's now placed
on the controlplane node.

09:23.800 --> 09:25.153
Earlier in the beginning,

09:25.233 --> 09:27.660
the controlplane node
has a taint set on it

09:27.846 --> 09:30.280
and then we set taint on node01.

09:30.866 --> 09:35.353
Then we created the mosquito pod.

09:35.900 --> 09:38.840
It was not placed on any of the nodes

09:38.920 --> 09:40.806
because both of them
had a taint then.

09:41.373 --> 09:45.066
Then we created the bee pod
with the toleration or node01

09:45.146 --> 09:49.593
so the bee pod
was able to be placed on node01.

09:49.986 --> 09:52.613
Then we removed
the taint on controlplane.

09:53.160 --> 09:55.946
Without doing anything
the pod mosquito

09:56.026 --> 09:57.800
was automatically placed
on controlplane

09:57.880 --> 10:01.386
because it no longer has
any taint on it.

10:03.126 --> 10:04.620
The answer to this is controlplane.

10:05.606 --> 10:08.433
Okay, so that's the end of this lab.

