WEBVTT

00:00.500 --> 00:03.286
In this video, we're going to go over

00:03.366 --> 00:05.453
this lab on static pods.

00:06.300 --> 00:07.683
The first question is,

00:07.763 --> 00:12.003
how many static pods exist
in the cluster in all of the namespaces?

00:12.083 --> 00:18.353
Let's do a get pods -A,
to list the pods in all namespaces.

00:19.283 --> 00:25.023
Now, one way to figure out
or differentiate a static pod

00:25.103 --> 00:28.687
from the other pods is to look at its name.

00:28.793 --> 00:33.127
At the end,
you'll have the node name appended to it.

00:33.743 --> 00:37.203
This one, this one, this.

00:37.283 --> 00:40.053
This is a static pod
created on controlplane.

00:40.133 --> 00:43.353
All of these three are as well as this.

00:43.433 --> 00:44.913
There are four static pods,

00:44.993 --> 00:50.827
and then there are no others with
a visible node name to the end of it.

00:51.263 --> 00:53.013
That's one way to look at it.

00:53.093 --> 00:58.773
Another way to be sure is to look
at one of the pod in a bit more detail.

00:58.853 --> 01:05.213
Let's say, for example, this one,
let's do a kubectl get pod.

01:06.126 --> 01:11.853
Then we provide a name space,

01:11.933 --> 01:13.793
which is kube-system.

01:16.193 --> 01:17.883
This is just going to list the pods.

01:17.963 --> 01:20.073
It's not going to give
us the information that we need.

01:20.153 --> 01:24.743
We need to look
at the YAML format of the pod.

01:24.953 --> 01:27.923
We're going to do a -o and YAML.

01:28.943 --> 01:31.953
This is going to give
us a lot of information.

01:32.033 --> 01:37.653
From this, what we need to do is we need
to look at the owner reference section.

01:37.733 --> 01:42.573
If you scroll down, there's this section
called owner references.

01:42.653 --> 01:47.543
Under this, you'll see
the owner of this pod is the node,

01:48.173 --> 01:51.033
the kind is node,
and the name is controlplane.

01:51.113 --> 01:57.743
That's one way to be sure
if a pod is a static pod or not.

02:01.146 --> 02:03.063
Let's clear the screen.

02:05.333 --> 02:09.287
If you look at the same for another pod

02:09.367 --> 02:12.713
that is not a static pod,

02:15.833 --> 02:21.567
kube-system -o YAML output.

02:21.833 --> 02:25.333
If we look at the owner reference for this

02:26.903 --> 02:28.003
right here,

02:28.373 --> 02:32.123
we see that the owner
of this is a ReplicaSet.

02:33.383 --> 02:35.466
This is not a static pod.

02:35.573 --> 02:37.773
That's one way to figure that out.

02:37.853 --> 02:42.533
There are ways
that you can do this for all of the pods,

02:42.833 --> 02:45.303
like using filters and selectors.

02:45.383 --> 02:50.243
Now, we should be able to traverse
this file,

02:50.753 --> 02:54.087
and then we look at the owner reference.

02:54.413 --> 02:59.313
We haven't learned about filters
and advanced kubectl commands yet.

02:59.393 --> 03:02.133
We'll skip that for now,
but this is an easy way.

03:02.213 --> 03:07.563
There are two ways to find
out if a pod is static or not

03:07.643 --> 03:11.853
and one of that is to look
for no names at the end of it.

03:11.933 --> 03:15.243
To be sure,
you can use the command that is issued.

03:15.323 --> 03:17.943
We know that there are four static pods

03:18.023 --> 03:21.523
and they're all on controlplane as of now.

03:24.100 --> 03:26.518
Let's run that command again.

03:27.983 --> 03:29.820
The question is,
which of the below components

03:29.900 --> 03:32.693
is not deployed as a static pod?

03:34.043 --> 03:37.833
If you look at this,
we have the ETCD, the controlplane.

03:37.913 --> 03:39.183
ETCD is a static pod.

03:39.263 --> 03:40.863
Kube-apiserver is a static pod.

03:40.943 --> 03:42.603
Kube-controller-manager is a static pod,

03:42.683 --> 03:45.600
and kube-scheduler is a static pod.

03:47.200 --> 03:48.787
Node coredns.

03:48.867 --> 03:53.784
Coredns does not seem to be a static pod,
let's select that.

03:55.343 --> 03:58.563
Which of the below components
is not deployed as a static pod?

03:58.643 --> 04:02.893
Again, we know that all of these are

04:04.000 --> 04:08.783
except for the kube-proxy.

04:09.833 --> 04:12.833
The kube-proxy is not a static pod.

04:14.873 --> 04:17.253
On which nodes are the static
pods created currently?

04:17.333 --> 04:21.250
All of these as we just saw
are on controlplane.

04:21.443 --> 04:25.110
Controlplane is the answer to this question.

04:26.093 --> 04:32.593
Now, what is the path of the directory
holding the static pod definition files?

04:34.043 --> 04:40.883
One way to figure that out
is to look at the kubelet conf, so

04:45.713 --> 04:49.763
var/lib/kubelet, then we have a config.yaml.

04:50.723 --> 04:54.633
If you look into this file,
this is the kubelet configuration

04:54.713 --> 04:59.880
and we've learned that it is the kubelet
that creates the pods.

05:00.173 --> 05:03.993
There is this specification
here that says static pod path

05:04.073 --> 05:09.490
and it is currently set
to the etc/kubernetes/manifests directory.

05:09.773 --> 05:16.493
Let's look at that directory,
and we see that they are the files

05:16.583 --> 05:19.113
that are used to create the static pods.

05:19.193 --> 05:22.383
That is /etc/kubernetes/manifests.

05:22.463 --> 05:26.047
That's the correct answer to this question.

05:26.693 --> 05:30.360
Also remember that this is the path to check

05:30.736 --> 05:37.313
the static pod configuration
on any given node.

05:39.323 --> 05:42.093
How many pod definition files
are present in the manifests folder?

05:42.173 --> 05:43.233
That's one, two, three, four.

05:43.313 --> 05:44.043
Four.

05:44.123 --> 05:49.123
That is equal to the number
of static pods that we have here.

05:50.333 --> 05:51.903
Now, what is the docker image used to deploy

05:51.983 --> 05:54.423
the kube-api server as a static pod?

05:54.503 --> 05:58.033
If you look at kube-api server file here,

05:59.200 --> 06:03.503
so this followed by this.

06:05.213 --> 06:08.363
If we look into the image,

06:09.023 --> 06:09.787
we see that it's

06:09.867 --> 06:15.767
k8s.gcr.io/kube-apiserver:v1.20.0.

06:16.253 --> 06:19.753
As of this recording, this is the version.

06:19.973 --> 06:23.703
You should make sure that whatever
the version is that you're working on,

06:23.783 --> 06:27.117
make sure you choose that as the answer.

06:27.923 --> 06:30.033
The next question is to create a static pod

06:30.113 --> 06:37.283
named static-busybox that uses
the busybox image and the command sleep.

06:39.263 --> 06:43.847
We know that the command
to create a pod is kubectl run,

06:44.183 --> 06:48.323
and the name is static busybox.

06:49.403 --> 06:52.200
The image is busybox,

06:52.833 --> 06:59.093
and the command is sleep 1000.

07:00.473 --> 07:05.140
Now, what we need to do is,
we don't want to create this.

07:05.543 --> 07:08.823
Instead, we just want
to get the pod definition file

07:08.903 --> 07:12.987
and place it in the static
pod path for this node.

07:14.219 --> 07:17.153
We're going to do a dry run for this.

07:17.233 --> 07:18.513
Dry run here.

07:18.593 --> 07:21.003
Now, when you use the command option,

07:21.083 --> 07:24.123
always remember not to place any option

07:24.203 --> 07:27.787
that is for the kubectl command after this.

07:28.583 --> 07:31.953
Anything that you put after this,
especially after the two dashes here,

07:32.033 --> 07:35.163
is going to be considered
as an option for this command,

07:35.243 --> 07:37.077
so not place anything.

07:37.403 --> 07:40.503
The command should always be at the end.

07:40.583 --> 07:44.553
In this case, I'm going to put
the dry run before the command option.

07:44.633 --> 07:49.713
Any option for the kubectl utility
should be before the command option.

07:49.793 --> 07:54.293
Dry run equals client, and then -o yaml.

07:55.763 --> 07:56.933
I get this.

07:58.467 --> 08:01.717
We're going to redirect that to a file.

08:02.273 --> 08:06.803
For now, I'm going to put
it to static-busybox.yaml.

08:09.893 --> 08:12.833
Then we're going to move this to

08:13.346 --> 08:19.067
/etc/Kubernetes/manifests folder.

08:19.913 --> 08:23.133
Let's see if that was created.

08:23.213 --> 08:27.963
Okay, so the pod is now created,
static-busybox-controlplane,

08:28.043 --> 08:30.377
and it's in a running state.

08:31.600 --> 08:33.383
Let's go next.

08:34.343 --> 08:35.393
Now, edit

08:38.633 --> 08:45.413
the image on the static pod
to use the busybox:1.28.4 image.

08:47.200 --> 08:49.203
To make any changes to a static pod,

08:49.283 --> 08:52.867
you could simply edit the file and save it.

08:53.333 --> 08:55.753
Let's just go to edit the file

08:55.833 --> 09:00.683
in etc/kubernetes/manifests static pod.

09:02.123 --> 09:06.067
Then let's change this right here,

09:07.533 --> 09:10.073
busybox:1.28.4,

09:11.693 --> 09:13.373
and just save that.

09:13.643 --> 09:18.473
If we look at the pod now, it's pending.

09:21.143 --> 09:23.061
Let's watch the status.

09:28.900 --> 09:32.033
There's an ImagePull issue.

09:36.433 --> 09:37.820
I got it wrong.

09:37.900 --> 09:39.580
Sorry about that.

09:40.793 --> 09:42.626
Let's change that now.

09:49.400 --> 09:52.803
That's why you should always
verify after you do anything,

09:52.883 --> 09:54.801
especially in the exam.

09:55.673 --> 10:00.507
It's possible that we might make
typos in different places.

10:00.593 --> 10:04.343
You always verify
your work after you're done.

10:06.053 --> 10:07.253
That's done.

10:13.403 --> 10:16.223
Let's wait for the next question.

10:20.273 --> 10:23.673
We just created a new static
pod named static-greenbox.

10:23.753 --> 10:25.586
Find it and delete it.

10:25.800 --> 10:26.900
Let's see.

10:27.923 --> 10:29.043
Kubectl get pods.

10:29.123 --> 10:32.343
We see that there is indeed
a static-greenbox.

10:32.423 --> 10:34.553
We have got to delete it.

10:34.973 --> 10:41.903
Now, if we just try
to delete the pod like this--

10:49.163 --> 10:52.830
It says it's deleted, but if you look at it,

10:53.033 --> 10:54.933
it's going to be recreated because we know

10:55.013 --> 10:57.363
that it's a pod that the kubectl manages.

10:57.443 --> 11:01.683
It's not possible to delete a static
pod just using the delete command.

11:01.763 --> 11:05.763
It would delete
it but it would be created again.

11:07.069 --> 11:11.353
We need to find the manifest
file for that static pod and delete it.

11:11.433 --> 11:12.846
If you look at

11:12.933 --> 11:19.103
the etc/kubernetes/manifests/ directory,

11:19.763 --> 11:22.323
we'll see that there is none
for the greenbox,

11:22.403 --> 11:27.063
and that's basically because if you look
at the name of the static pod,

11:27.143 --> 11:29.193
you see that it's created on node01.

11:29.273 --> 11:32.093
We've got to go the node01

11:32.543 --> 11:35.993
and delete it from there.

11:36.923 --> 11:39.453
Let's find out how to go to node01.

11:39.533 --> 11:42.993
Let's do a kubectl nodes command.

11:43.073 --> 11:47.990
We see that we have indeed
a controlplane and a node01 node.

11:48.173 --> 11:53.993
If you do a -o wide,
we'll see that it has an IP address.

11:54.653 --> 11:58.700
The controlplane is at 10.38.102.6,

11:59.000 --> 12:03.033
and node01 is at 10.38.102.8.

12:03.400 --> 12:07.163
Let's ssh to node01.

12:10.467 --> 12:14.467
Sometimes depending on how the DNS
is configured,

12:14.753 --> 12:18.243
if you just do a ssh to just node01,
that might work too.

12:18.323 --> 12:19.520
If that isn't working,

12:19.600 --> 12:21.483
then you should always
look up at the internal IP

12:21.563 --> 12:24.363
address following this command
and ssh to that node.

12:24.443 --> 12:26.193
Now, we're on node01.

12:27.323 --> 12:31.907
All we need to do is find
the static file manifest path.

12:32.800 --> 12:36.717
Let's go
to etc/kubernetes/manifests/ directory.

12:37.583 --> 12:40.001
As you see, it doesn't exist.

12:40.163 --> 12:43.613
There is no static-greenbox path here.

12:45.533 --> 12:47.783
We need to see why that is.

12:48.623 --> 12:53.013
Let's go back and see
the kubelet configuration

12:53.093 --> 12:58.253
and find out what's wrong with
the path to the static pod.

13:00.096 --> 13:01.353
The file is

13:01.433 --> 13:08.433
/var/lib/kubelet

13:13.193 --> 13:15.693
and then you have config.yaml.

13:17.573 --> 13:21.093
If you look at this file,
we have the static pod path.

13:21.173 --> 13:25.820
As you can see, it's not at

13:25.900 --> 13:27.653
etc/kubernetes/manifests/.

13:27.733 --> 13:28.687
It's actually changed.

13:28.767 --> 13:31.553
It is at etc/just-to-mess-with-you.

13:31.633 --> 13:38.333
That's a change we made just
to get you to think a little bit.

13:40.823 --> 13:44.073
There indeed we have the greenbox.yaml.

13:44.873 --> 13:49.207
All we need to do is just
remove this file from here.

13:55.853 --> 13:57.771
Make sure it's removed.

13:58.643 --> 14:02.477
Now, let's exit and go
back to the controlplane

14:04.853 --> 14:07.253
and list the nodes.

14:13.553 --> 14:17.453
Let's watch and wait
for it to be terminated.

14:21.023 --> 14:23.691
The pod is now being terminated.

14:27.467 --> 14:28.667
That's gone.

14:30.800 --> 14:32.000
That's that.

14:32.367 --> 14:34.617
That's the end of this lab.

