WEBVTT

00:00.380 --> 00:03.950
-This is the solution video for
the commands and arguments lab.

00:05.960 --> 00:08.280
For the first question,
we have to find the number

00:08.280 --> 00:09.430
of pods on the system.

00:09.960 --> 00:13.270
Let's go to the terminal
and type kubectl get pods.

00:15.530 --> 00:19.290
You can see that there is
already a pod deployed, which

00:19.290 --> 00:21.090
is called ubuntu-sleeper.

00:22.450 --> 00:23.910
The answer is one.

00:26.240 --> 00:30.280
Next, find out the command used
to run the pod ubuntu-sleeper.

00:33.520 --> 00:37.680
To find this we can run the
command kubectl describe pod and

00:37.900 --> 00:43.150
the pod name, ubuntu-sleeper,
and let's look for the command.

00:44.120 --> 00:46.430
That is set to sleep 4,800.

00:48.070 --> 00:49.920
Select that from the options.

00:52.910 --> 00:57.040
Next, we have to create a pod
with the ubuntu image to run our

00:57.040 --> 00:59.650
container to sleep for 5,000 seconds.

01:01.100 --> 01:04.860
To do this, we'll modify a file
that has been provided already, and

01:04.870 --> 01:07.940
it's called ubuntu-sleeper-2.yaml.

01:10.260 --> 01:11.350
Go to the terminal.

01:12.130 --> 01:17.820
First, let's copy the name
of the YAML file, and we

01:17.820 --> 01:19.790
are in the /root directory.

01:20.410 --> 01:27.670
Edit this file, and we are going
to add a command section here, and

01:27.670 --> 01:30.700
the value should be sleep 5,000.

01:32.110 --> 01:37.310
Save this file, and let's
try to create the pod.

01:43.770 --> 01:45.580
Looks like I've made a mistake.

01:46.010 --> 01:47.920
There is an unknown
field called commands, so

01:47.940 --> 01:49.650
there's a typo in the file.

01:49.660 --> 01:51.650
It should be command, not commands.

01:51.670 --> 01:54.020
Let's correct that
and try that again.

01:58.660 --> 02:01.090
This time the pod has been created.

02:02.570 --> 02:07.580
We can validate that the pod has been
created correctly with the command by

02:07.590 --> 02:14.240
using the kubectl describe, and yes,
it has the command for sleep 5,000.

02:15.090 --> 02:17.850
Let's go ahead and
check the solution.

02:23.910 --> 02:28.430
Moving on the next question, we
have to create a pod using another

02:28.440 --> 02:31.690
file called ubuntu-sleeper-3.yaml.

02:32.270 --> 02:34.480
There is something wrong with
it, so we have to fix it.

02:36.560 --> 02:42.820
Let's copy the YAML file, and we'll
attempt to create the pod using

02:42.830 --> 02:45.800
kubectl apply and look for errors.

02:49.120 --> 02:53.960
There is an error here, so let's
go and check the YAML file.

03:00.890 --> 03:04.920
You'll see that in the command
section the seconds have not

03:04.920 --> 03:07.430
been described correctly, so it
should be within double-quotes.

03:08.720 --> 03:09.840
Let's change that.

03:09.920 --> 03:11.780
Save the file and try again.

03:21.930 --> 03:23.730
Let's move on to the next question.

03:27.270 --> 03:31.350
We have to update the
pod ubuntu-sleeper-3 to

03:31.350 --> 03:33.050
sleep for 2000 seconds.

03:38.480 --> 03:43.460
First, let's delete the
existing pod, ubuntu-sleeper-3.

03:43.940 --> 03:46.780
Wait for the pod to be
terminated completely.

03:47.330 --> 03:55.970
Once that is done, will edit the file
again and change the command to 2000.

03:56.980 --> 03:59.820
This can take a few
seconds, so be patient.

04:01.300 --> 04:03.340
The pod has been terminated.

04:04.530 --> 04:12.630
Let's update the file and change
the seconds from 1200 to 2000.

04:13.560 --> 04:18.930
Now see this file and recreate
the pod using kubectl apply.

04:22.050 --> 04:22.650
Moving on.

04:24.370 --> 04:27.910
Now we have to inspect the
Dockerfile, which is located

04:27.920 --> 04:32.350
at /root/webapp-color and
find out the command that is

04:32.360 --> 04:34.230
run at the container startup.

04:35.340 --> 04:43.260
To do this we will open the
Dockerfile in that location and

04:43.300 --> 04:49.580
look for the entry point, which
is defined within the Dockerfile.

04:50.560 --> 04:56.050
If you look at the bottom here, the
entry point is set to python app.py.

04:59.750 --> 05:02.290
Let's choose that as our answer.

05:07.270 --> 05:11.000
Now we have to inspect another
Dockerfile called the Dockerfile2

05:11.750 --> 05:13.270
given at the same location.

05:14.160 --> 05:18.320
We have to find the command that
will run at the container startup.

05:18.320 --> 05:21.390
Same as before.
Let's inspect the Dockerfile2.

05:25.900 --> 05:28.860
In this case you'll notice
that the Dockerfile2 has

05:28.870 --> 05:30.780
both entry point and command.

05:31.810 --> 05:35.290
Effectively, the command that would
be run during container startup

05:35.300 --> 05:39.430
is python app.py --color red.

05:46.110 --> 05:51.330
Now let's inspect the two files
under the directory webapp-color-2.

05:52.160 --> 05:55.370
What is the command that will be
run during the container startup?

05:55.520 --> 05:57.710
Let's go and check those two files.

05:58.070 --> 05:59.960
Copy the directory name.

06:00.370 --> 06:08.130
Go back to root, and let's go inside
this directory and list the files.

06:08.140 --> 06:12.860
There is a Dockerfile2, and there
is a YAML file for that pod.

06:13.210 --> 06:15.310
First let's inspect the Dockerfile2.

06:22.030 --> 06:24.690
It's same as the last question.

06:24.810 --> 06:30.850
It has got an entry point
python app.py, and it has got

06:30.880 --> 06:33.510
a command section --color red.

06:34.750 --> 06:38.630
Now let's inspect the YAML file,
which will be used to create the pod.

06:40.660 --> 06:44.550
The pod will make use of the image
created from that Dockerfile.

06:45.050 --> 06:49.330
In this case, you'll see that
the pod has just one command

06:49.340 --> 06:51.770
field, which is --color green.

06:52.530 --> 06:57.680
If you remember from the lecture,
you'll know that the command field

06:57.710 --> 07:01.410
in the Kubernetespod definition
file will override the entry point.

07:01.890 --> 07:04.250
There is no argument
section provided here.

07:04.560 --> 07:08.580
Effectively, the command that
will be run during the startup

07:08.610 --> 07:12.040
of this pod is --color green.

07:15.880 --> 07:18.100
Let's select that as our answer.

07:24.390 --> 07:27.720
For the next question, we have
to do the same thing in another

07:27.730 --> 07:32.220
directory called webapp-color-3,
and find out the command that will

07:32.220 --> 07:33.830
run during the container startup.

07:34.420 --> 07:41.370
Let's copy that directory and change
directory into webapp-color-3,

07:43.450 --> 07:45.380
and let's check out the files.

07:45.450 --> 07:50.720
First thing as before, we'll
check out the Dockerfile and

07:50.740 --> 07:52.390
it's exactly the same as before.

07:52.510 --> 07:56.290
There's an entry point, python
app.py, and the command,

07:56.690 --> 08:01.240
which comes after that is
--color, and the value is red.

08:02.290 --> 08:04.250
Now, let's check out
the pod definition file.

08:08.820 --> 08:12.790
Here you'll notice that the
pod definition has both command

08:12.800 --> 08:15.850
and arguments, so effectively,
it will override everything

08:15.850 --> 08:17.650
that is there in the Dokerfile.

08:18.400 --> 08:22.610
During the startup, the command
that would be run is python

08:22.620 --> 08:27.290
app.py followed by the arguments,
which is color is equal to pink.

08:29.480 --> 08:33.950
Let's choose that as the
answer, python, app.py,

08:33.990 --> 08:35.120
color is equal to pink.

08:36.930 --> 08:40.130
Finally, we have to create a pod
with the given specification.

08:41.290 --> 08:44.060
By default, it displays
a blue background.

08:44.540 --> 08:47.850
Set the given command line
arguments to change it to green.

08:49.170 --> 08:51.360
The pod name is webapp-green.

08:52.090 --> 08:56.090
Image is kodekloud/webapp-color, and
we have have to provide the command

08:56.090 --> 08:59.150
line arguments of --color=green.

09:03.540 --> 09:04.650
Let's do that.

09:05.340 --> 09:15.440
Go back to the terminal, and
let's create a pod definition

09:15.470 --> 09:20.610
file using kubectl run.
Name of the pod --image.

09:21.220 --> 09:23.580
It is called cloud webapp-color.

09:28.300 --> 09:34.020
We'll use the --dry-run and -0 yaml
to create a pod definition file.

09:34.570 --> 09:36.600
Let's store it in pod.yaml.

09:39.100 --> 09:41.630
I forgot, --restart
is equal to never.

09:42.430 --> 09:43.760
Make sure that you add that in.

09:45.690 --> 09:48.170
Now let's update the pod.yaml file.

09:50.850 --> 09:55.960
Under the container section,
I'm going to add a new field

09:57.180 --> 10:03.040
for arguments is equal to
color as equal to green.

10:06.040 --> 10:10.610
I can just copy it from the
question, --color is equal to green.

10:17.080 --> 10:28.050
Now let's create this pod, and check
that it has been created correctly.

10:28.350 --> 10:31.230
Run our kubectl describe
and inspect the arguments.

10:31.330 --> 10:34.540
Let us say two --color=green.

10:36.550 --> 10:37.760
Let's validate the answer.

10:38.790 --> 10:39.650
That's correct.

10:40.090 --> 10:42.950
Thank you for joining me
in this lab solution video.

10:43.290 --> 10:44.620
I'll see you on the next one.

