WEBVTT

00:01.033 --> 00:05.723
Let's go over the solution
for the labs on pods.

00:05.963 --> 00:09.113
In this lab,
we're going to get familiar with pods.

00:10.613 --> 00:14.813
The first question is,
how many pods exist on the system?

00:15.683 --> 00:19.143
Now, we know that we can get the information

00:19.223 --> 00:21.873
about pods using the kubectl
get pods command.

00:21.953 --> 00:22.773
That's what we learned.

00:22.853 --> 00:25.753
We're going to run
the kubectl get pods command.

00:26.123 --> 00:28.023
You can ignore this line here that says

00:28.103 --> 00:29.583
in the current(default) namespace.

00:29.663 --> 00:32.883
We're going to talk about namespaces
in one of the upcoming lectures.

00:32.963 --> 00:34.743
You don't have to worry about that for now.

00:34.823 --> 00:38.223
This is for those who already
know what a namespace is.

00:38.303 --> 00:40.953
If you know, then just make
sure you're checking the number

00:41.033 --> 00:43.596
of pods in the current default namespace.

00:44.843 --> 00:48.993
When we're on the kubectl get pods
command, we see the result is zero.

00:49.073 --> 00:50.886
There are no resources found.

00:51.353 --> 00:53.353
We're going to select zero here.

00:56.723 --> 00:58.703
The next is a task.

00:59.153 --> 01:02.903
We've got to create
a new pod with the Nginx image.

01:04.163 --> 01:10.673
To create a pod, the easiest way
is to run the kubectl run command

01:11.243 --> 01:12.923
and we specify the image.

01:13.313 --> 01:15.513
We have to specify a name and an image.

01:15.593 --> 01:19.553
If you're not sure about the syntax,
run the help command.

01:20.123 --> 01:24.863
We see the name of the pod
followed by the image.

01:24.983 --> 01:25.593
This format.

01:25.673 --> 01:27.353
We're going to run that.

01:28.583 --> 01:30.083
Kubectl run.

01:30.893 --> 01:34.293
Since there's no specification
about the name of the pod,

01:34.373 --> 01:36.811
so we could basically name it anything,

01:36.983 --> 01:39.421
but the image name has to be the Nginx.

01:41.513 --> 01:42.938
The pod is created.

01:48.323 --> 01:50.886
Okay. Now, how many pods are created now?

01:51.893 --> 01:54.123
We've created a few more pods,
so please check again.

01:54.203 --> 01:56.753
Let's run kubectl get pods command.

01:59.213 --> 02:01.593
In addition to the Nginx
pod that we created,

02:01.673 --> 02:05.783
there are a few other pods
that were created by us, basically.

02:06.503 --> 02:11.183
There are, in total, one, two,
three, four pods at the moment.

02:11.333 --> 02:12.683
Let's select four.

02:15.893 --> 02:18.603
What is the image used
to create the new pods?

02:18.683 --> 02:23.123
You must look at one of the new pods
in detail to figure this out.

02:25.223 --> 02:26.853
Let's pick one of the pods.

02:26.933 --> 02:27.933
This one.

02:29.903 --> 02:32.553
We already know
that to look at it in detail,

02:32.633 --> 02:35.393
we've got to run the kubectl describe [?].

02:39.533 --> 02:42.243
Now we have additional
details about the pod.

02:42.323 --> 02:44.073
This is the name of the pod.

02:44.513 --> 02:47.693
You have the start time
and a number of other details.

02:48.473 --> 02:52.193
The question is, what is the image
used to create the new pods?

02:53.363 --> 02:56.423
We know that this tells us the containers.

02:58.073 --> 03:00.973
Here you have the image
and the image is BusyBox.

03:01.667 --> 03:03.242
Let's select BusyBox.

03:07.073 --> 03:10.133
Now, which nodes are these pods placed on?

03:10.493 --> 03:13.973
You must look at all the pods
in detail to figure this out.

03:15.053 --> 03:18.993
One way to do this is we've already run
the kubectl describe pod command,

03:19.073 --> 03:23.573
and we can see
that this is on node control plane.

03:24.743 --> 03:29.633
We could actually run the describe
command against each pod.

03:29.903 --> 03:32.028
That's one way to figure that out.

03:32.423 --> 03:35.993
Another way and an easier
way is to just run kubectl

03:36.953 --> 03:39.773
get pods command with the wide option.

03:41.453 --> 03:45.363
Here you get to see the node,
and it says control plane.

03:45.443 --> 03:50.753
All of the new pods are created
on the control plane node.

03:51.413 --> 03:52.988
Select control plane.

03:57.413 --> 04:02.423
How many containers
are part of the pod webapp?

04:03.533 --> 04:06.233
There's a new pod created.

04:06.743 --> 04:07.743
This one.

04:09.833 --> 04:12.653
Get pods command to see webapp.

04:14.123 --> 04:16.763
If you look at this column right here,

04:17.213 --> 04:20.373
it shows us the total number
of containers part of the pod.

04:20.453 --> 04:22.623
This number right here
is the total number of containers.

04:22.703 --> 04:27.983
That's one way to figure that out,
or we always run the describe command.

04:32.273 --> 04:36.383
To see that in detail,
here you see containers,

04:36.563 --> 04:39.273
then you have one container here,
it's Nginx,

04:39.353 --> 04:41.166
and the other one right here.

04:41.963 --> 04:43.776
Those are the two containers.

04:44.153 --> 04:45.203
We select two.

04:48.833 --> 04:52.493
Then you have, what images
are used in the new webapp pod?

04:53.213 --> 04:56.693
You must look at all the pods
in detail to figure this out.

04:57.293 --> 05:01.323
Actually, it should be, you must look
at all the containers. in detail.

05:01.403 --> 05:03.216
Here you have two containers.

05:07.583 --> 05:13.343
If you look here,
you see that the image for nginx is nginx,

05:14.093 --> 05:17.403
and the one for agentx is called agentx.

05:17.483 --> 05:19.163
There's nginx and agentx.

05:20.183 --> 05:22.563
Those are the images
used for those containers.

05:22.643 --> 05:23.643
This one.

05:26.873 --> 05:31.433
Now, what is the state of the container
agentx in the podweb app?

05:31.853 --> 05:37.167
If you look at the container here,
and you see there is a state

05:38.199 --> 05:42.173
and it is in a waiting state at the moment.

05:42.863 --> 05:44.883
Out of these, it's not running,
ready, or success,

05:44.963 --> 05:47.033
it's actually error or waiting.

05:47.813 --> 05:49.823
This is the state.

05:53.633 --> 05:56.587
Now, why do you think the container agentx

05:56.667 --> 06:00.623
in podweb app
is in an error or waiting state?

06:01.973 --> 06:05.213
Try to figure it out
from the event section of the pod.

06:05.393 --> 06:10.533
If you look at one of the section
here under state,

06:10.613 --> 06:13.488
you have the reason
called as error image pull,

06:13.643 --> 06:18.083
or if you just look at it below here
in the event section,

06:18.713 --> 06:22.533
you can see the error,
which is basically this one.

06:22.613 --> 06:24.053
It says, "Failed to pull image

06:24.133 --> 06:31.133
agentx@docker.io/libraries/agentx."

06:32.333 --> 06:35.153
This image by the name agentx does not exist

06:35.873 --> 06:38.773
and that's basically
the reason that is failing.

06:39.443 --> 06:41.163
The correct answer is a Docker image with

06:41.243 --> 06:44.063
this name doesn't exist on Docker hub.

06:48.293 --> 06:50.073
Now, what does
the ready column in the output

06:50.153 --> 06:52.323
of the kubectl get pods command indicate?

06:52.403 --> 06:56.243
If you go up here, we have the output
of the get pods command.

06:56.603 --> 07:02.273
Here you see you have 1/1 here,
and then you have 1/2.

07:03.143 --> 07:04.143
What does this mean?

07:04.223 --> 07:05.220
Now, we know that

07:05.300 --> 07:08.363
this is the total containers within the pod,

07:08.813 --> 07:12.233
and this is basically, of course,
the ones that are ready.

07:12.503 --> 07:16.193
At the moment,
there's only one ready out of the two,

07:16.883 --> 07:20.753
and we know
that because this image does not exist.

07:21.023 --> 07:24.143
Of course,
that's why that container isn't ready yet.

07:24.503 --> 07:27.003
It's basically the total containers
that are ready/just

07:27.083 --> 07:31.703
the total containers within the pod.

07:32.543 --> 07:36.063
That's total containers
in the pod or running containers

07:36.143 --> 07:38.581
in the pod/total containers in the pod.

07:39.233 --> 07:40.913
That's the correct answer.

07:43.133 --> 07:45.508
The next task is to delete the webapp.

07:48.019 --> 07:55.019
Let's run the kubectl delete
command and delete the webapp pod.

07:56.933 --> 07:58.508
Okay. That's deleted.

08:01.300 --> 08:02.980
Let's go to the next one.

08:03.533 --> 08:07.883
Create a new pod with the name
redis and with the image redis123.

08:10.133 --> 08:13.433
The recommendation is to use
a pod definition YAML file,

08:13.703 --> 08:17.613
and the image name is wrong.

08:17.693 --> 08:19.631
Yes, the image's name is wrong.

08:20.183 --> 08:22.103
We could do this in two ways.

08:22.283 --> 08:25.183
As we know,
we could run the kubectl run command.

08:26.063 --> 08:32.453
The name of the pod is redis,
and the name of the image is redis123.

08:33.683 --> 08:35.733
You could basically
just create it like this,

08:35.813 --> 08:40.223
but we just want to get familiar
with generating the YAML file

08:40.583 --> 08:43.263
and creating it with
the pod definition file.

08:43.343 --> 08:46.267
Let's use the dry run option

08:46.667 --> 08:50.033
and output

08:50.300 --> 08:54.953
the commands in a YAML format.

09:00.743 --> 09:06.000
This is basically a command and it says

09:06.300 --> 09:08.223
the dry run command is deprecated

09:08.303 --> 09:10.983
and is replaced with
the dry run equals client.

09:11.063 --> 09:12.188
Let's run that.

09:14.483 --> 09:15.920
This is the YAML file.

09:16.000 --> 09:19.163
Let's direct it to a file.

09:19.403 --> 09:21.083
We'll call it redis.yaml.

09:28.733 --> 09:32.903
We have the YAML definition
for that pod and this file,

09:33.113 --> 09:37.733
so we're now going to create
the pod using the kubectl create

09:39.593 --> 09:40.553
or apply command.

09:40.633 --> 09:43.283
Let's go with the create command.

09:44.483 --> 09:45.903
Okay. It's created.

09:45.983 --> 09:49.600
Let's verify that it's created.

09:55.560 --> 09:58.500
It's created and it's in an error
image pull state

09:58.633 --> 10:00.946
because we have the wrong image name.

10:01.233 --> 10:02.808
Let's click on check.

10:03.983 --> 10:05.993
Okay, it's successful.

10:06.803 --> 10:08.320
The last question for this lab

10:08.400 --> 10:11.103
is to change the image on this pod to redis,

10:11.183 --> 10:14.093
to fix that error
that we purposefully created,

10:15.473 --> 10:17.848
and to get the pod in a running state.

10:18.503 --> 10:19.773
Again, there are two ways to do that.

10:19.853 --> 10:26.813
You could run the kebectl
edit command to edit the pod,

10:27.143 --> 10:31.953
or since we already
have the redis file we could jut go in

10:32.033 --> 10:34.443
and change the file we created.

10:34.523 --> 10:36.098
Let's go and do that.

10:40.913 --> 10:44.063
I've changed the image name.

10:45.023 --> 10:49.253
I'm just going to apply the changes.

10:53.753 --> 10:55.493
Let's check redis.

10:58.733 --> 11:01.553
We'll talk about this error message later

11:02.033 --> 11:03.693
when we talk about imperative commands

11:03.773 --> 11:06.773
and the declarative way that we apply.

11:07.493 --> 11:09.618
For now, let's stick to the basics

11:10.523 --> 11:13.523
and let's just make sure
the change was successful.

11:14.633 --> 11:16.353
When you're on the kubectl get pods command,

11:16.433 --> 11:20.003
we see that the pod is in a running state.

11:21.200 --> 11:22.200
I'll check.

11:23.453 --> 11:24.453
All right.

11:25.433 --> 11:26.703
That's the end of the lab.

11:26.783 --> 11:28.596
Let's hit the end lab button.

11:29.513 --> 11:31.326
I'll see you in the next one.

