Let's go over the solution for the labs on pods.
In this lab, we're going to get familiar with pods.
The first question is, how many pods exist on the system?
Now, we know that we can get the information
about pods using the kubectl get pods command.
That's what we learned.
We're going to run the kubectl get pods command.
You can ignore this line here that says
in the current(default) namespace.
We're going to talk about namespaces in one of the upcoming lectures.
You don't have to worry about that for now.
This is for those who already know what a namespace is.
If you know, then just make sure you're checking the number
of pods in the current default namespace.
When we're on the kubectl get pods command, we see the result is zero.
There are no resources found.
We're going to select zero here.
The next is a task.
We've got to create a new pod with the Nginx image.
To create a pod, the easiest way is to run the kubectl run command
and we specify the image.
We have to specify a name and an image.
If you're not sure about the syntax, run the help command.
We see the name of the pod followed by the image.
This format.
We're going to run that.
Kubectl run.
Since there's no specification about the name of the pod,
so we could basically name it anything,
but the image name has to be the Nginx.
The pod is created.
Okay. Now, how many pods are created now?
We've created a few more pods, so please check again.
Let's run kubectl get pods command.
In addition to the Nginx pod that we created,
there are a few other pods that were created by us, basically.
There are, in total, one, two, three, four pods at the moment.
Let's select four.
What is the image used to create the new pods?
You must look at one of the new pods in detail to figure this out.
Let's pick one of the pods.
This one.
We already know that to look at it in detail,
we've got to run the kubectl describe [?].
Now we have additional details about the pod.
This is the name of the pod.
You have the start time and a number of other details.
The question is, what is the image used to create the new pods?
We know that this tells us the containers.
Here you have the image and the image is BusyBox.
Let's select BusyBox.
Now, which nodes are these pods placed on?
You must look at all the pods in detail to figure this out.
One way to do this is we've already run the kubectl describe pod command,
and we can see that this is on node control plane.
We could actually run the describe command against each pod.
That's one way to figure that out.
Another way and an easier way is to just run kubectl
get pods command with the wide option.
Here you get to see the node, and it says control plane.
All of the new pods are created on the control plane node.
Select control plane.
How many containers are part of the pod webapp?
There's a new pod created.
This one.
Get pods command to see webapp.
If you look at this column right here,
it shows us the total number of containers part of the pod.
This number right here is the total number of containers.
That's one way to figure that out, or we always run the describe command.
To see that in detail, here you see containers,
then you have one container here, it's Nginx,
and the other one right here.
Those are the two containers.
We select two.
Then you have, what images are used in the new webapp pod?
You must look at all the pods in detail to figure this out.
Actually, it should be, you must look at all the containers. in detail.
Here you have two containers.
If you look here, you see that the image for nginx is nginx,
and the one for agentx is called agentx.
There's nginx and agentx.
Those are the images used for those containers.
This one.
Now, what is the state of the container agentx in the podweb app?
If you look at the container here, and you see there is a state
and it is in a waiting state at the moment.
Out of these, it's not running, ready, or success,
it's actually error or waiting.
This is the state.
Now, why do you think the container agentx
in podweb app is in an error or waiting state?
Try to figure it out from the event section of the pod.
If you look at one of the section here under state,
you have the reason called as error image pull,
or if you just look at it below here in the event section,
you can see the error, which is basically this one.
It says, "Failed to pull image
agentx@docker.io/libraries/agentx."
This image by the name agentx does not exist
and that's basically the reason that is failing.
The correct answer is a Docker image with
this name doesn't exist on Docker hub.
Now, what does the ready column in the output
of the kubectl get pods command indicate?
If you go up here, we have the output of the get pods command.
Here you see you have 1/1 here, and then you have 1/2.
What does this mean?
Now, we know that
this is the total containers within the pod,
and this is basically, of course, the ones that are ready.
At the moment, there's only one ready out of the two,
and we know that because this image does not exist.
Of course, that's why that container isn't ready yet.
It's basically the total containers that are ready/just
the total containers within the pod.
That's total containers in the pod or running containers
in the pod/total containers in the pod.
That's the correct answer.
The next task is to delete the webapp.
Let's run the kubectl delete command and delete the webapp pod.
Okay. That's deleted.
Let's go to the next one.
Create a new pod with the name redis and with the image redis123.
The recommendation is to use a pod definition YAML file,
and the image name is wrong.
Yes, the image's name is wrong.
We could do this in two ways.
As we know, we could run the kubectl run command.
The name of the pod is redis, and the name of the image is redis123.
You could basically just create it like this,
but we just want to get familiar with generating the YAML file
and creating it with the pod definition file.
Let's use the dry run option
and output
the commands in a YAML format.
This is basically a command and it says
the dry run command is deprecated
and is replaced with the dry run equals client.
Let's run that.
This is the YAML file.
Let's direct it to a file.
We'll call it redis.yaml.
We have the YAML definition for that pod and this file,
so we're now going to create the pod using the kubectl create
or apply command.
Let's go with the create command.
Okay. It's created.
Let's verify that it's created.
It's created and it's in an error image pull state
because we have the wrong image name.
Let's click on check.
Okay, it's successful.
The last question for this lab
is to change the image on this pod to redis,
to fix that error that we purposefully created,
and to get the pod in a running state.
Again, there are two ways to do that.
You could run the kebectl edit command to edit the pod,
or since we already have the redis file we could jut go in
and change the file we created.
Let's go and do that.
I've changed the image name.
I'm just going to apply the changes.
Let's check redis.
We'll talk about this error message later
when we talk about imperative commands
and the declarative way that we apply.
For now, let's stick to the basics
and let's just make sure the change was successful.
When you're on the kubectl get pods command,
we see that the pod is in a running state.
I'll check.
All right.
That's the end of the lab.
Let's hit the end lab button.
I'll see you in the next one.