WEBVTT

00:00.106 --> 00:02.201
Let's get started with

00:02.259 --> 00:04.753
the solution video for Mock Exam 3.

00:05.086 --> 00:07.289
Before we begin,

00:07.723 --> 00:09.437
I just want to quickly highlight,

00:09.692 --> 00:12.729
if you go to the Linux Foundation

00:14.099 --> 00:16.048
documentation page on the important

00:16.048 --> 00:18.043
instructions for CKA and CKAD,

00:18.208 --> 00:20.453
you get a lot of details here about the exam,

00:20.453 --> 00:22.853
which we have discussed.

00:23.413 --> 00:24.678
One thing I want to highlight

00:24.678 --> 00:26.140
is if you scroll down,

00:26.760 --> 00:29.042
you will see this section where

00:30.281 --> 00:32.283
it says all environments,

00:33.391 --> 00:34.630
the base system and cluster nodes,

00:34.630 --> 00:35.517
have the following additional

00:35.517 --> 00:36.800
command-line utilities installed.

00:36.800 --> 00:38.060
You have the kubectl,

00:38.218 --> 00:40.184
the k alias and Bash autocompletion.

00:40.184 --> 00:41.490
All of these are already done.

00:41.776 --> 00:44.501
You have also the jq utility

00:44.739 --> 00:46.046
and then tmux and curl

00:46.046 --> 00:47.709
and other are also there.

00:47.808 --> 00:49.338
You don't really have to worry about

00:49.592 --> 00:51.347
configuring this or installing this

00:51.347 --> 00:52.720
in the exam environments.

00:53.539 --> 00:56.576
Let's get started with the first question.

00:57.141 --> 00:58.947
Create a new serviceAccount

00:58.947 --> 01:00.964
with the name pvviewer

01:01.047 --> 01:02.625
and grant the serviceAccount access

01:02.625 --> 01:04.416
to list all PersistentVolumes

01:04.416 --> 01:05.709
in the cluster by creating

01:05.709 --> 01:06.877
an appropriate clusterrole

01:06.877 --> 01:08.375
called pvviewer-role

01:08.375 --> 01:09.590
and ClusterRoleBinding called

01:09.590 --> 01:11.423
pvviewer-role-binding.

01:11.675 --> 01:14.324
Then create a pod called pvviewer

01:14.487 --> 01:15.459
with the image redis

01:15.459 --> 01:16.979
and serviceAccount pvviewer

01:16.979 --> 01:18.147
in the default namespace.

01:18.964 --> 01:20.346
A few things to do with respect

01:20.346 --> 01:21.871
to serviceAccount, clusterroles,

01:21.871 --> 01:22.955
and ClusterRoleBindings,

01:22.955 --> 01:25.561
and then finally to create a pod using those.

01:25.903 --> 01:26.693
Let's get started.

01:27.687 --> 01:29.408
The first step is to create a serviceAccount.

01:29.408 --> 01:33.081
Let's do a kubectl or the short form k ctl,

01:33.476 --> 01:36.266
create serviceAccount.

01:37.401 --> 01:39.592
Let's us check the help real quick.

01:39.694 --> 01:41.534
It's just creating serviceAccount

01:41.534 --> 01:42.625
and serviceAccount name.

01:43.320 --> 01:47.030
It's that simple. Create serviceAccount,

01:47.090 --> 01:50.450
and the account name is pvviewer.

01:52.176 --> 01:53.910
The next step is to grant

01:53.910 --> 01:55.294
this serviceAccount access

01:55.294 --> 01:56.858
to list all PersistentVolumes in the cluster

01:56.858 --> 01:59.105
by creating an appropriate clusterrole

01:59.246 --> 02:00.552
called pvviewer-role.

02:00.627 --> 02:02.305
Let's create a role.

02:02.802 --> 02:07.578
That's kubectl create clusterrole.

02:08.087 --> 02:09.762
Let's check the help.

02:10.332 --> 02:12.353
You have kubectl create clusterrole,

02:12.353 --> 02:13.260
the role name,

02:13.323 --> 02:14.596
and then the verb and resource.

02:15.338 --> 02:16.368
Let's pick that.

02:19.612 --> 02:22.496
The clusterrole is going to be

02:25.052 --> 02:26.147
pvviewer-role,

02:26.984 --> 02:29.532
and the verb is just list,

02:31.966 --> 02:33.042
and then you have--

02:34.911 --> 02:36.237
It is to list all

02:36.269 --> 02:38.055
PersistentVolumes in the cluster,

02:38.336 --> 02:40.298
so this has to be PersistentVolumes,

02:40.688 --> 02:43.306
but if you're not sure if it's PersistentVolumes

02:43.306 --> 02:45.236
or just PersistentVolume,

02:45.510 --> 02:46.176
what you can do

02:46.176 --> 02:47.423
is I'm just going to park it there.

02:47.423 --> 02:50.065
Let's just do a kubectl api-resources

02:50.426 --> 02:53.146
and look for Persistent.

02:54.278 --> 02:54.732
All right.

02:54.732 --> 02:55.990
We have PersistentVolumeClaims

02:55.990 --> 02:56.850
and PersistentVolume.

02:56.850 --> 02:57.837
This is what we want,

02:58.453 --> 03:00.283
so let us go back to that

03:00.320 --> 03:02.967
and just paste that in.

03:05.663 --> 03:06.904
It's PersistentVolumes.

03:08.579 --> 03:09.827
That should be that.

03:10.218 --> 03:11.997
The next step is to create

03:11.997 --> 03:13.258
a ClusterRoleBinding called

03:13.258 --> 03:17.061
pvviewer-role-binding to bind

03:17.827 --> 03:20.193
that serviceAccount to that clusterrole.

03:21.403 --> 03:28.206
That's kubectl create ClusterRoleBinding.

03:29.241 --> 03:30.307
Let's take a look at the help.

03:30.349 --> 03:32.567
Create ClusterRoleBinding, the name,

03:32.736 --> 03:33.791
the clusterrole.

03:35.624 --> 03:36.957
Here you have user and group,

03:36.957 --> 03:37.830
but that's not what we want.

03:37.830 --> 03:40.215
We want serviceAccount with namespace

03:40.215 --> 03:41.103
and serviceAccount.

03:41.124 --> 03:42.981
That's what we're going to do.

03:43.619 --> 03:45.078
It's like that.

03:49.117 --> 03:53.682
The ClusterRoleBinding name has to be this,

03:54.797 --> 03:57.907
the clusterrole is this,

03:59.435 --> 04:01.876
and we want serviceAccount,

04:06.200 --> 04:09.723
just serviceAccount=.

04:10.770 --> 04:12.795
Then the serviceAccount that we created

04:12.795 --> 04:14.157
is pvviewer.

04:14.746 --> 04:15.847
We're going to do that.

04:15.985 --> 04:16.986
When we do that,

04:17.008 --> 04:18.242
it says it must be

04:18.242 --> 04:19.456
in the namespace name format.

04:20.383 --> 04:22.072
Just remember to put in

04:23.059 --> 04:25.248
the default namespace so it always

04:25.248 --> 04:26.315
requires a namespace,

04:26.501 --> 04:28.186
so even if you accidentally forgot it,

04:28.387 --> 04:30.046
it would tell you, give you this error message,

04:30.046 --> 04:32.286
and you'll know that

04:32.477 --> 04:33.907
have to put in the namespace.

04:34.201 --> 04:35.536
That part is done.

04:35.672 --> 04:37.512
Let's quickly verify.

04:38.329 --> 04:40.688
Describe clusterrole

04:41.801 --> 04:43.343
pvvviewer-role.

04:44.504 --> 04:46.487
We have PersistentVolumes in list.

04:46.637 --> 04:47.323
That's good.

04:47.600 --> 04:50.429
Then we have ClusterRoleBinding,

04:51.369 --> 04:54.446
and it's role-binding.

04:56.176 --> 04:58.256
That's for serviceAccount pvviewer

04:58.256 --> 04:59.386
in the default namespace.

04:59.718 --> 05:02.242
The role is pvviewer-role.

05:02.392 --> 05:03.406
That's good.

05:03.568 --> 05:05.280
Next, we have to create a pod.

05:05.500 --> 05:08.991
Let's do a kubectl run pvviewer

05:10.060 --> 05:11.321
with the image redis,

05:11.350 --> 05:13.488
so that's image=redis

05:14.237 --> 05:16.397
and the serviceAccount pvviewer.

05:16.397 --> 05:20.598
We do have an option with the run itself.

05:20.656 --> 05:21.595
We run command itself

05:21.595 --> 05:23.658
to provide a serviceAccount.

05:23.893 --> 05:25.655
That's just serviceAccount=

05:25.990 --> 05:27.345
and then we can just specify

05:27.345 --> 05:28.273
the serviceAccount.

05:30.324 --> 05:32.707
If we do a kubectl get pods,

05:33.592 --> 05:36.603
you see that we have the pvviewer pod.

05:37.961 --> 05:39.442
It's in a container creating state,

05:39.442 --> 05:41.018
and it's now in a running state.

05:41.512 --> 05:44.506
If you look at the pod

05:47.733 --> 05:49.835
in the YAML output,

05:51.059 --> 05:52.901
we can see if it has serviceAccount.

05:53.093 --> 05:55.025
Yes, here we have the serviceAccount

05:55.025 --> 05:56.053
and serviceAccount name,

05:56.467 --> 05:57.221
which is correct.

05:58.792 --> 06:01.629
That's about that question.

06:01.735 --> 06:02.930
Let's go the next one.

06:04.436 --> 06:05.873
In this question,

06:06.118 --> 06:08.494
we have to list the InternalIP

06:08.545 --> 06:09.903
of all nodes of the cluster,

06:10.138 --> 06:11.362
and we have to save the results

06:11.379 --> 06:12.962
to a file node_ips.

06:13.202 --> 06:14.499
The answer should be in the format

06:14.499 --> 06:16.310
InternalIP of controlplane

06:16.329 --> 06:18.278
InternalIP of node, et cetera.

06:19.360 --> 06:21.323
Let''s do a kubectl get nodes.

06:22.164 --> 06:23.840
These are the nodes.

06:23.840 --> 06:24.928
Let's do a wide.

06:25.558 --> 06:27.175
Here, we get the InternalIPs.

06:27.493 --> 06:29.951
The goal is to get this in the form--

06:30.213 --> 06:32.778
If there are multiple nodes,

06:32.945 --> 06:36.746
then in order to get it in a particular format,

06:36.746 --> 06:37.626
which is basically

06:37.723 --> 06:40.021
all the InternalIP addresses of all the nodes,

06:40.266 --> 06:42.397
and then direct that to this file.

06:44.591 --> 06:46.589
For this, we use the JSONPath.

06:46.615 --> 06:49.915
Let's go to the kubectl cheat sheet

06:49.915 --> 06:53.146
and look for JSONPath options.

06:55.054 --> 06:57.020
Here, we have get nodes

06:57.042 --> 06:58.717
and the JSONPath,

06:58.800 --> 07:00.458
different options for JSONPath.

07:00.800 --> 07:02.552
Let's let's try and find out

07:02.552 --> 07:05.575
how we're going to identify where that is.

07:05.575 --> 07:07.437
We need to find out InternalIP.

07:07.663 --> 07:10.121
Let's just do a -o json.

07:10.370 --> 07:12.916
This gives us this in JSON format.

07:13.311 --> 07:14.926
Now, what we need to do is,

07:14.926 --> 07:16.509
if you use the jq utility,

07:16.574 --> 07:19.037
it formats well so you can see it

07:19.580 --> 07:20.591
in a better way.

07:22.089 --> 07:24.138
Now, there's so much information,

07:24.138 --> 07:26.099
and it's going to be hard to find out

07:26.513 --> 07:28.850
where the information

07:28.850 --> 07:29.985
that you're looking for is.

07:31.595 --> 07:34.007
One thing we could do is we could use

07:34.033 --> 07:37.614
the -c option for JSONPath.

07:37.667 --> 07:40.220
It has something called as paths.

07:40.950 --> 07:46.264
That's basically jq -c and then 'paths'.

07:46.467 --> 07:50.283
It's going to list all the paths to every field

07:50.584 --> 07:53.372
within this, within the output.

07:54.480 --> 08:01.522
If we now search for InternalIP here,

08:02.009 --> 08:05.090
we should be able to see some information.

08:05.796 --> 08:07.287
If you look at it,

08:07.287 --> 08:09.015
most of these are within

08:09.015 --> 08:10.918
the metadata and managedfields.

08:12.123 --> 08:14.109
All of these have this f before it.

08:14.109 --> 08:17.321
These are basically just fields

08:17.343 --> 08:18.850
that are part of the metadata.

08:18.850 --> 08:19.694
This is not what we want.

08:19.694 --> 08:20.346
We want to find out

08:20.346 --> 08:22.504
the actual current IP address.

08:23.616 --> 08:26.252
If we go back and look at this output,

08:28.504 --> 08:32.778
one thing we could do is go back

08:32.800 --> 08:35.151
and look at this output

08:35.488 --> 08:40.273
I grep for InternalIP.

08:43.903 --> 08:47.335
We see that InternalIP is actually

08:47.335 --> 08:50.172
a value for what's called as type.

08:50.552 --> 08:54.610
Let's say, if we do a 5 before

08:54.610 --> 08:57.912
and 5 after just to see a little bit extra,

08:58.174 --> 09:00.075
we see that there's something called

09:00.075 --> 09:01.410
a status and then you have address.

09:02.143 --> 09:04.753
Within addresses, you have these addresses.

09:05.420 --> 09:07.260
The InternalIP is just a type.

09:08.329 --> 09:10.213
What we're really looking for is type,

09:10.787 --> 09:12.736
so let's go back.

09:15.616 --> 09:19.723
Let's go back to the JSONPaths that we had.

09:19.823 --> 09:21.415
Instead of searching for InternalIP,

09:21.415 --> 09:22.659
let's search for type.

09:23.658 --> 09:25.789
We see a lot of stuff.

09:26.012 --> 09:26.972
Now, as we discussed,

09:26.972 --> 09:29.163
we don't want the metadata sections,

09:29.347 --> 09:34.179
so let's just try and remove those,

09:34.584 --> 09:35.873
so "metadata".

09:37.076 --> 09:39.103
We get a much smaller list this time.

09:39.367 --> 09:41.425
If you look at it, you have items,

09:41.425 --> 09:43.025
status, addresses, and type.

09:43.616 --> 09:44.984
There's also item, status,

09:45.066 --> 09:45.920
conditions, and type,

09:45.920 --> 09:47.743
but we're not really interested in conditions.

09:48.050 --> 09:50.766
It's ideally items, status, addresses,

09:50.766 --> 09:51.510
and type.

09:51.648 --> 09:54.273
Maybe we can just further filter that

09:54.494 --> 09:56.957
to just search for address.

09:57.221 --> 09:58.152
We get these.

10:00.133 --> 10:02.768
This is comparatively a complex example,

10:03.020 --> 10:05.200
but these are different ways that you can--

10:05.573 --> 10:06.535
These are different techniques

10:06.535 --> 10:09.941
that you can follow to identify the path

10:09.941 --> 10:14.261
that you can use in the JSONPath query

10:14.261 --> 10:15.287
that you're going to use.

10:15.740 --> 10:19.161
Here, just by filtering, just by using paths,

10:19.253 --> 10:20.249
it lists all the paths.

10:20.249 --> 10:21.095
Then from that,

10:21.095 --> 10:23.309
we just filter down the stuff

10:23.309 --> 10:24.576
that we actually needed.

10:24.744 --> 10:27.144
You have items, and then this is an array.

10:27.287 --> 10:28.736
If you have like 10 nodes,

10:28.875 --> 10:30.911
there's going to be 10 of these.

10:31.183 --> 10:32.339
Then you have status,

10:32.579 --> 10:33.629
and then you have address,

10:33.682 --> 10:34.819
and then this is an array,

10:34.913 --> 10:35.983
and then you have type.

10:37.258 --> 10:39.306
That’s what we are going to follow.

10:39.326 --> 10:44.133
Let's do a kubectl get nodes -o JSONPath.

10:47.013 --> 10:48.727
We're going to have this format.

10:49.175 --> 10:52.036
Then within here, we're going to use items,

10:56.273 --> 10:57.476
just items.

11:01.920 --> 11:04.814
JSONPath, it has to be equals,

11:06.880 --> 11:09.357
JSONPath=items,

11:11.226 --> 11:12.962
that’s .items.

11:16.033 --> 11:17.721
If you want to see this in a format

11:17.721 --> 11:18.538
where you could use,

11:18.538 --> 11:21.032
you could just pass in jq at the end of it.

11:21.461 --> 11:22.370
You have items,

11:22.370 --> 11:24.547
and we know that items is an array.

11:24.666 --> 11:28.334
If we look at the output that

11:28.334 --> 11:33.296
we originally got from this,

11:33.437 --> 11:35.146
so you have items,

11:35.260 --> 11:36.431
and then you have an array,

11:36.547 --> 11:38.543
and then you have status, addresses,

11:38.603 --> 11:39.789
and then array and type.

11:40.780 --> 11:43.136
You have items and then you have an array.

11:43.156 --> 11:44.867
If you want the addresses

11:44.887 --> 11:46.644
for all the items in the array,

11:46.644 --> 11:48.913
that's all the nodes, then you can put a *.

11:49.081 --> 11:50.431
If you're just looking for the first one,

11:50.431 --> 11:51.452
you can just go to 0.

11:51.452 --> 11:52.773
Let's just do one at a time.

11:52.773 --> 11:54.167
Let's just do a 0.

11:54.383 --> 11:58.593
This basically gets me the item 0,

11:58.593 --> 11:59.825
which is node 0,

12:00.111 --> 12:02.179
and then you have status under it.

12:02.179 --> 12:04.307
Let's put status.

12:06.870 --> 12:08.797
This is just a status section.

12:11.440 --> 12:13.847
Then under status, you have--

12:15.650 --> 12:17.667
You have status and then you have addresses.

12:18.724 --> 12:23.677
Let's put addresses and you get this.

12:24.545 --> 12:27.381
We have items of 0, so this is the first node,

12:27.570 --> 12:29.054
and then you have status,

12:29.129 --> 12:30.033
and then you have addresses.

12:30.206 --> 12:31.927
These addresses is an array.

12:32.050 --> 12:34.627
That’s what we saw here.

12:35.313 --> 12:37.081
Let's just run that command again.

12:38.923 --> 12:40.409
Status and then addresses.

12:40.409 --> 12:41.881
Addresses is an array,

12:42.053 --> 12:44.312
which is what you can see

12:44.375 --> 12:46.293
by these brackets here.

12:46.538 --> 12:47.929
Then it has two items.

12:48.315 --> 12:50.989
What we could do is just--

12:51.895 --> 12:55.585
If you want to print all of the--

12:57.197 --> 12:58.812
everything within

12:59.018 --> 13:00.303
these particular addresses--

13:00.320 --> 13:00.683
All right.

13:00.683 --> 13:01.585
There are two items--

13:01.630 --> 13:04.138
you could just put a * and then say .

13:04.186 --> 13:05.823
What we really need is this address,

13:06.625 --> 13:07.939
so that's what we're going to put.

13:08.598 --> 13:09.932
There's no longer--

13:10.019 --> 13:11.890
You use jq because we're no longer

13:12.198 --> 13:15.430
getting JSON format at output.

13:16.390 --> 13:17.192
You have addresses

13:17.192 --> 13:18.373
and then you have .address,

13:18.373 --> 13:20.625
and that gave us the IP address.

13:20.790 --> 13:22.058
It says controlplane,

13:22.058 --> 13:23.856
and this controlplane is basically this.

13:24.487 --> 13:26.160
You have the IP address and controlplane.

13:26.332 --> 13:27.970
Controlplane is just the hostname,

13:28.087 --> 13:30.412
and this is actually the InternalIP.

13:30.632 --> 13:32.446
We don’t need this.

13:32.446 --> 13:33.498
We don’t need the hostname

13:33.498 --> 13:34.545
because it does not ask us

13:34.545 --> 13:35.549
to print the hostname.

13:35.704 --> 13:37.961
It only asks us to print the InternalIP.

13:37.961 --> 13:40.501
This is where we could use a filter

13:40.707 --> 13:43.277
to filter this out of this

13:43.304 --> 13:44.523
and just only have this.

13:44.596 --> 13:46.625
The goal is from out of this array,

13:46.775 --> 13:49.764
we filter out this that we don’t want,

13:49.980 --> 13:51.122
and we just get this.

13:51.381 --> 13:55.095
For that, there's this example of a filter,

13:55.178 --> 13:56.237
if you can see here.

13:56.579 --> 13:58.070
For example, this one.

13:58.271 --> 14:00.853
Within addresses, there's this filter

14:00.901 --> 14:02.567
that just filters out ExternalIP,

14:02.809 --> 14:04.346
but we're going to use the same filter,

14:04.346 --> 14:05.823
and we're going to use

14:05.878 --> 14:07.478
InternalIP in this case.

14:07.478 --> 14:10.227
Instead of *, we're put that filter,

14:10.480 --> 14:13.321
and then put that query,

14:13.522 --> 14:16.184
and then we're going to put InternalIP.

14:24.322 --> 14:26.945
Now, we have the InternalIP

14:26.945 --> 14:28.293
of one node printed.

14:28.293 --> 14:30.656
Just to get InternalIP of all the nodes,

14:30.686 --> 14:32.652
all we have to do is, instead of 0,

14:32.652 --> 14:33.963
we just put a * here,

14:34.572 --> 14:36.363
and we get the InternalIP of both the nodes.

14:36.550 --> 14:39.840
Then the goal is to just redirect that to file,

14:41.987 --> 14:43.076
and then make sure that file

14:43.076 --> 14:44.787
has that information.

14:45.505 --> 14:47.129
That’s what this is about.

14:47.757 --> 14:51.006
The first step is to identify the path

14:51.328 --> 14:53.098
to what we want to retrieve,

14:53.398 --> 14:56.370
and then instead of the 0s and 1s,

14:56.370 --> 14:57.423
you always put a *

14:57.490 --> 15:00.266
depending on what you want to display.

15:00.644 --> 15:02.421
Then in this case,

15:02.421 --> 15:04.635
we wanted to just get the 0s only,

15:04.635 --> 15:07.277
so we just put a filter there.

15:07.503 --> 15:08.850
The same thing is going to work

15:08.850 --> 15:09.704
if you just put 0,

15:09.704 --> 15:11.813
because 0 InternalIP is always for 0,

15:11.813 --> 15:13.544
but just to be more accurate in case

15:13.544 --> 15:14.751
there are multiple items,

15:14.904 --> 15:16.312
in case there are like ExternalIPs,

15:16.312 --> 15:17.796
InternalIPs and hostnames

15:18.070 --> 15:20.928
to always actually just fetch InternalIPs,

15:21.042 --> 15:22.104
which is more reliable.

15:22.375 --> 15:24.640
Something like this is more reliable.

15:24.938 --> 15:26.627
There are many other examples here

15:27.294 --> 15:28.511
so you can follow.

15:29.018 --> 15:31.301
If you can figure this out,

15:31.517 --> 15:33.030
then you can most likely figure out

15:33.347 --> 15:35.680
any kind of JSON queries

15:35.680 --> 15:36.974
that you might come across.

15:38.373 --> 15:39.369
That's that.

15:40.332 --> 15:43.442
Let's go to the next question.

15:45.124 --> 15:46.882
Here, we have to create a pod called

15:46.882 --> 15:48.344
multi-pod with two containers.

15:48.375 --> 15:50.543
Container 1 with the name alpha

15:50.543 --> 15:51.556
and image nginx.

15:51.585 --> 15:53.490
Container 2 with the name beta

15:53.563 --> 15:55.117
and image busybox.

15:57.781 --> 16:00.227
The command, sleep 4800,

16:00.227 --> 16:01.907
this is for the busybox container.

16:02.162 --> 16:04.247
Then you have environment variables.

16:04.438 --> 16:07.018
Container 1 should have name in alpha,

16:07.018 --> 16:08.327
and Container 2 to have the environment

16:08.327 --> 16:09.493
variable name beta.

16:09.730 --> 16:11.219
That's what it is.

16:11.219 --> 16:12.741
We know that we can create

16:13.309 --> 16:14.703
a container report using

16:14.703 --> 16:16.882
the kubectl run command.

16:19.410 --> 16:21.726
The goal is to create a pod

16:22.346 --> 16:23.825
with multiple containers.

16:25.107 --> 16:29.156
It's going to be kubectl run multi--

16:29.263 --> 16:31.621
It's basically called multi-pod

16:32.179 --> 16:33.478
for multi-pod container,

16:33.549 --> 16:37.369
multi-container pod and two containers.

16:37.716 --> 16:39.549
I could use the imperative command

16:39.549 --> 16:41.309
to create a pod with a single container,

16:41.536 --> 16:43.743
but I cannot use the imperative command

16:43.743 --> 16:45.292
to create a pod with two containers.

16:45.483 --> 16:47.430
I'm going to have to pick

16:47.430 --> 16:48.940
one of these containers and create with it,

16:48.940 --> 16:51.932
and then add in, and do a dry-run,

16:51.980 --> 16:53.241
redirect it to a file,

16:53.287 --> 16:54.412
and then add the other details.

16:54.911 --> 16:55.646
What I'm going to do

16:55.646 --> 16:57.376
is I'm going to pick this one

16:57.376 --> 16:59.180
because it's just easier to just put

16:59.255 --> 17:00.579
more additional details.

17:00.579 --> 17:02.841
I can specify in the command line

17:02.875 --> 17:04.353
as part of the imperative command.

17:04.353 --> 17:06.416
That way, once I put it to a file,

17:06.601 --> 17:10.809
I just have to easily add the other pod.

17:11.023 --> 17:11.757
I'm going to pick

17:11.757 --> 17:14.416
the bit more complex container,

17:14.416 --> 17:16.184
which is the one that has sleep,

17:16.351 --> 17:17.575
that we later add.

17:17.575 --> 17:18.543
I have less work,

17:18.543 --> 17:19.493
so I'm just going to do

17:19.493 --> 17:21.505
a kubectl run multi-pod.

17:23.187 --> 17:26.506
Image is going to be busybox.

17:28.160 --> 17:29.752
We have a command,

17:30.147 --> 17:32.664
so I'm going to specify command.

17:33.301 --> 17:36.259
The command is going to be sleep 4800.

17:37.132 --> 17:39.425
Now, I'm going to do a dry-run.

17:40.572 --> 17:44.751
dry-run=client.

17:46.193 --> 17:48.157
I'm going to output that to a YAML file.

17:49.309 --> 17:50.387
Let's check that out.

17:52.421 --> 17:54.596
I just lost my alias.

17:55.122 --> 17:55.932
I'll fix that.

17:57.088 --> 17:58.392
Here's the file.

17:58.855 --> 18:04.266
I'm going to redirect that to multi-pod.yaml,

18:06.055 --> 18:08.431
and then I'm going to edit the file.

18:09.103 --> 18:13.197
Here, we have pod called multi-pod,

18:13.197 --> 18:14.916
so the name of the pod is multi-pod.

18:14.928 --> 18:15.587
That's fine.

18:15.789 --> 18:16.809
The first container--

18:16.809 --> 18:18.273
This is actually the first container.

18:18.273 --> 18:20.397
It says the first container should be alpha,

18:20.606 --> 18:22.225
but in this case it's the busybox.

18:22.225 --> 18:24.336
Anyway, we're just going to add

18:24.843 --> 18:26.009
the first container in.

18:26.009 --> 18:29.517
The first container name is going to be alpha,

18:30.346 --> 18:33.689
and the image that it's going to use is nginx.

18:34.196 --> 18:35.357
Then the second container

18:35.357 --> 18:38.223
already has the command set to sleep 4800,

18:38.492 --> 18:40.254
the image is already set to busybox.

18:40.489 --> 18:42.145
The name is not multi-pod,

18:42.145 --> 18:45.151
so we're going to change that to beta.

18:46.332 --> 18:49.071
Then you have the DNSpolicy, restartpolicy,

18:49.277 --> 18:50.193
but then we also want to set

18:50.193 --> 18:51.306
environment variables.

18:52.082 --> 18:53.093
Container 1 should have

18:53.093 --> 18:55.010
the environment variable name alpha.

18:55.284 --> 18:56.223
Container 2 to have

18:56.223 --> 18:57.663
the environment variable beta.

18:57.907 --> 18:59.585
Here, we're going to add

18:59.793 --> 19:00.698
environment variables,

19:00.698 --> 19:01.583
but if you're not sure,

19:01.583 --> 19:07.105
you can quickly search just to be sure.

19:07.837 --> 19:10.019
You have ENV, and then you just need

19:10.019 --> 19:11.231
a name and value.

19:14.193 --> 19:15.401
You're going to have have ENV,

19:16.128 --> 19:18.727
and you're going to have name.

19:18.918 --> 19:20.635
It's name, alpha.

19:22.344 --> 19:24.475
Environment variables are to have

19:24.475 --> 19:25.376
name and value,

19:25.810 --> 19:32.923
so name is going to be name,

19:34.208 --> 19:37.420
and value is going to be alpha.

19:39.309 --> 19:41.847
Similarly, we're going to have one for this.

19:42.189 --> 19:46.290
ENV, we're going to have name

19:47.595 --> 19:48.380
goes with name

19:49.481 --> 19:54.761
and value is going to be beta.

20:01.626 --> 20:02.164
Yes.

20:07.035 --> 20:08.007
That's that.

20:08.176 --> 20:12.370
Let's go ahead and create the file.

20:20.249 --> 20:22.489
Let's now check the status of the pod,

20:23.311 --> 20:24.613
to see that it's in a creating state.

20:24.613 --> 20:28.189
Let's do a describe pod multi-pod.

20:28.921 --> 20:32.625
We see that it has two containers,

20:32.625 --> 20:34.586
alpha with the image nginx,

20:35.221 --> 20:37.081
and environment variable name alpha,

20:37.369 --> 20:40.210
and then beta with the image busybox,

20:40.276 --> 20:42.082
and the command sleep 4800,

20:42.082 --> 20:43.997
and the environment variable name beta.

20:46.145 --> 20:46.792
That's good.

20:46.792 --> 20:48.952
Let's proceed to the next one.

20:49.803 --> 20:51.161
The next one is to create a pod

20:51.161 --> 20:52.909
called a non-root-pod

20:54.121 --> 20:56.484
and with the redis:alpine image

20:56.530 --> 21:00.225
with the user 1000 and group 2000.

21:00.312 --> 21:05.282
We're going to do a kubectl run non-root-pod,

21:05.932 --> 21:11.263
and the image is going to be redis:alpine.

21:13.401 --> 21:14.259
We're just going to do

21:14.259 --> 21:22.455
a dry-runs=client -o yaml.

21:23.735 --> 21:24.632
We get the file,

21:24.632 --> 21:26.111
and we're just going to redirect that

21:26.227 --> 21:30.579
to non-root-pod.yaml.

21:40.157 --> 21:43.367
Then we need to set the security context,

21:43.534 --> 21:48.012
so let's just search for security context.

21:49.267 --> 21:51.200
Here, you have an example

21:51.522 --> 21:53.503
of security context for runAsUser

21:53.503 --> 21:57.503
and runAsGroup and fsGroup.

21:57.573 --> 22:00.101
What we really need is group.

22:05.200 --> 22:06.421
We're going to have that.

22:06.509 --> 22:09.226
The runAsUser is 1000, which is good.

22:09.503 --> 22:11.803
fsGroup is the next one,

22:12.179 --> 22:14.232
and that is 2000.

22:14.778 --> 22:17.590
That's good enough.

22:17.813 --> 22:22.019
Let's read file

22:23.536 --> 22:25.311
and let's do a describe.

22:30.715 --> 22:33.723
Here, we have the containers.

22:33.723 --> 22:35.059
You have non-root-pod.

22:35.423 --> 22:37.920
The image is redis:alpine.

22:43.122 --> 22:44.400
You have to look at--

22:50.872 --> 22:54.923
Let's look at the output in YAML format

22:57.583 --> 23:00.528
to verify the security context set.

23:01.718 --> 23:03.049
You have the security context,

23:03.049 --> 23:06.378
and you have the fsGroup 2000 runAsUser 1000.

23:07.410 --> 23:09.030
That's good.

23:09.544 --> 23:10.783
Let's go to the next one.

23:12.540 --> 23:13.743
We have deployed

23:13.784 --> 23:17.953
a new pod called np-test-1

23:18.979 --> 23:21.149
and a service called np-test-service.

23:21.694 --> 23:25.410
We have np-test-1,

23:25.410 --> 23:28.433
and we have np-test-service.

23:29.408 --> 23:31.071
Incoming connections to this service

23:31.071 --> 23:32.031
are not working,

23:32.109 --> 23:33.818
so troubleshoot and fix the issue.

23:34.041 --> 23:35.403
Create the network policy

23:35.403 --> 23:37.801
by the name ingress-to-nptest

23:37.801 --> 23:39.183
that allows incoming connections

23:39.183 --> 23:41.949
to the service over port 80,

23:42.904 --> 23:43.713
and don't delete

23:43.713 --> 23:45.842
any current objects deployed.

23:46.596 --> 23:51.614
First, to test this, we want to--

23:51.614 --> 23:52.863
We know that there's an issue,

23:52.863 --> 23:54.167
but we want to test it first,

23:54.443 --> 23:55.975
and find out what the issue is,

23:56.157 --> 23:58.397
and then apply our fix,

23:58.397 --> 23:59.658
and then we want to test it again

23:59.658 --> 24:00.703
to make sure that it's working.

24:01.095 --> 24:03.112
Let's run a temporary container.

24:03.168 --> 24:08.535
Let's run, let's say, a call or something.

24:09.893 --> 24:12.029
You could use busybox

24:12.111 --> 24:13.122
and do an n-KAD[?],

24:13.122 --> 24:14.395
or if you just want to do a curl

24:14.395 --> 24:15.966
because the port is 80,

24:16.157 --> 24:18.802
you can just do just use alpine curl.

24:19.728 --> 24:21.866
I'm just going to call it curl,

24:22.349 --> 24:24.511
and then we call it alphine.

24:25.013 --> 24:25.466
Oh.

24:27.553 --> 24:28.407
What we want to do

24:28.407 --> 24:30.535
is we don't want to just run it.

24:30.535 --> 24:31.871
We're only getting inside

24:32.312 --> 24:33.347
and just run a curl.

24:33.415 --> 24:36.901
I'm going to put the --rm to remove it

24:36.960 --> 24:39.864
once the container is killed,

24:40.150 --> 24:41.832
and then I'm going to put a -it

24:42.196 --> 24:44.635
and just sh into that.

24:45.740 --> 24:47.701
I forgot to specify the image.

24:50.613 --> 24:52.710
What I want to do is I want to run this,

24:54.096 --> 24:56.814
run a temporary pod called curl

24:57.183 --> 25:00.113
using the alpine/curl image and then,

25:00.259 --> 25:06.106
I’ll just get into it using the exec sh to shell,

25:06.106 --> 25:07.900
and now we can do a curl.

25:07.900 --> 25:11.595
I'm going to do a curl np-test-service.

25:14.690 --> 25:18.637
If it's working, it should return me

25:18.637 --> 25:21.316
whatever it is running on pod 80.

25:22.569 --> 25:24.809
That's what I'm going to try here.

25:28.751 --> 25:31.107
It doesn't look like it is responding,

25:32.050 --> 25:32.998
so let's leave that there

25:32.998 --> 25:34.383
and let's open a new terminal.

25:34.383 --> 25:36.494
We're going to start working on

25:36.889 --> 25:38.259
fixing the issue.

25:41.806 --> 25:43.917
The goal is to create a network policy,

25:44.106 --> 25:48.206
so let’s search for network policy.

25:52.528 --> 25:54.746
Here, we have sample of network policy.

25:55.381 --> 25:57.856
What we want to do is we want

25:57.900 --> 25:58.938
to create a network policy

25:58.938 --> 26:03.284
for the np-test-1 pod so that it can allow

26:03.284 --> 26:05.578
incoming connections on pod 80,

26:05.677 --> 26:06.792
so that's the goal.

26:06.792 --> 26:08.632
We need to create a network policy

26:08.632 --> 26:12.310
for ingress and allow anything

26:12.310 --> 26:13.352
that's coming on pod 80,

26:13.352 --> 26:14.082
so that's the goal.

26:14.082 --> 26:15.258
Let's copy this.

26:16.492 --> 26:19.517
Let's create network policy .yaml.

26:24.421 --> 26:26.366
We need to give it a name that's given here,

26:30.121 --> 26:31.476
so that's the name.

26:32.780 --> 26:35.360
The pod selector is supposed

26:35.360 --> 26:39.352
to be whatever labels are set for this,

26:39.352 --> 26:42.446
so I'm not sure what that is.

26:42.446 --> 26:43.881
We're going to find that out.

26:48.290 --> 26:50.210
Kubectl get odds

26:52.455 --> 26:56.816
and look at it in YAML format.

26:58.164 --> 27:08.176
We see any labels set on it.

27:08.186 --> 27:10.763
You have run np-test-1,

27:10.763 --> 27:11.675
so that's the label.

27:11.832 --> 27:13.090
That's what we were going to use

27:17.090 --> 27:18.567
to run np-test-1.

27:18.923 --> 27:20.198
All we need is ingress,

27:20.198 --> 27:22.264
so we're going to remove egress.

27:23.578 --> 27:25.643
For this use case, it's actually pretty simple.

27:25.726 --> 27:27.927
It should allow incoming connections

27:27.946 --> 27:29.932
to service whole pod 80,

27:30.344 --> 27:32.693
so we don't have a limit to any specific

27:32.693 --> 27:35.185
name, selector, or a pod, or IP addres.

27:35.197 --> 27:39.090
We can get rid of all of this, get rid of this.

27:39.098 --> 27:43.400
All we need to do is ports, so TCP port 80.

27:44.174 --> 27:47.350
We won't allow ingress traffic

27:47.350 --> 27:50.060
to any on pod 80 from anywhere.

27:50.715 --> 27:51.629
Let's save that.

27:54.625 --> 27:58.215
Let's create this file.

27:58.751 --> 28:01.364
Let's go back and test this again.

28:02.489 --> 28:03.507
This time, we see that

28:03.507 --> 28:04.642
we immediately got a response,

28:04.642 --> 28:07.241
so this is basically an nginx server.

28:07.692 --> 28:09.103
We got the welcome to nginx.

28:09.166 --> 28:12.947
That confirms that the issue is resolved.

28:14.373 --> 28:16.380
As soon as we exited the curl,

28:18.489 --> 28:19.818
the pod was deleted.

28:20.749 --> 28:23.956
That should help with that.

28:25.745 --> 28:28.174
The next one is to taint the worker node,

28:28.174 --> 28:30.271
node01, to be unschedulable.

28:31.304 --> 28:33.970
Once done, create a pod called dev-redis

28:34.528 --> 28:37.066
with the image redis:alpine

28:37.066 --> 28:38.555
to ensure workloads are not scheduled

28:38.555 --> 28:39.575
to this worker node.

28:39.687 --> 28:41.212
Then finally, create a new pod

28:41.212 --> 28:42.223
called prod-redis

28:42.380 --> 28:43.675
and the image redis:alpine

28:43.675 --> 28:45.878
with toleration to be scheduled on node01.

28:48.094 --> 28:50.593
The key to use is the environment type.

28:51.042 --> 28:52.179
The value is production,

28:52.283 --> 28:53.631
so that's how you should taint it.

28:53.949 --> 28:55.243
Operator is Equals,

28:55.265 --> 28:56.429
and the effect is NoSchedule.

28:56.540 --> 28:58.096
These details are given,

28:58.390 --> 28:59.677
so the goal is to taint the node

28:59.677 --> 29:03.801
with this information and then create a pod,

29:04.007 --> 29:06.496
dev-redis, to make sure that

29:06.581 --> 29:08.363
the taint is working so that

29:08.363 --> 29:10.460
it's not sheduled on node01,

29:10.739 --> 29:13.025
and then we have to create another pod,

29:13.464 --> 29:15.282
prod-redis,

29:15.883 --> 29:18.412
with the toleration so it's set on that,

29:18.664 --> 29:20.305
on node01.

29:20.722 --> 29:23.018
Let's first do a kubectl taint.

29:24.385 --> 29:25.636
Let's check the help.

29:26.664 --> 29:30.783
We have node, node name,

29:30.906 --> 29:35.570
and the environment key, and the effect.

29:35.740 --> 29:36.785
We'll just use that.

29:39.110 --> 29:41.415
Node is node01.

29:44.084 --> 29:48.353
The key is env_type.

29:50.526 --> 29:54.307
The value is production,

29:56.172 --> 29:57.975
and the effect is NoSchedule.

29:59.032 --> 29:59.992
Let's do that.

30:00.235 --> 30:02.060
Let's check the node now.

30:03.723 --> 30:07.275
Kubectl describe node01.

30:09.212 --> 30:13.711
We see the taint set as expected,

30:13.711 --> 30:14.945
so we have environment type,

30:15.059 --> 30:16.400
and production, and NoSchedule.

30:17.449 --> 30:18.271
That's good.

30:18.572 --> 30:20.669
The next step is to create

30:20.669 --> 30:22.227
a pod called dev-redis.

30:22.916 --> 30:28.555
Kubectl run dev-redis, image=redis:alpine.

30:30.424 --> 30:31.456
That's it.

30:31.540 --> 30:32.543
Let's run that.

30:33.575 --> 30:36.584
Let's look at the pod

30:37.035 --> 30:38.334
and see where it is scheduled.

30:38.792 --> 30:41.098
As you can see, the dev-redis pod

30:41.098 --> 30:42.855
is scheduled on controlplane,

30:43.061 --> 30:44.761
because it doesn't have the toleration

30:44.986 --> 30:45.932
for node01.

30:47.367 --> 30:49.083
It's running, so that's good.

30:49.648 --> 30:51.078
The next step is to create

30:51.078 --> 30:52.923
a new pod called prod-redis.

30:53.047 --> 30:56.640
Let's do a kubectl run prod-redis.

30:56.783 --> 31:00.720
The image has to be redis:alpine

31:01.241 --> 31:04.824
with the toleration to be scheduled on node01.

31:06.562 --> 31:08.489
Let's move these two.

31:09.023 --> 31:12.945
Let's do a dry-run=client,

31:13.466 --> 31:15.881
and let's output this to YAML format.

31:16.305 --> 31:19.776
Let's call it prod-redis.yaml

31:21.178 --> 31:22.227
and then we do--

31:25.539 --> 31:26.758
Let's edit this,

31:26.758 --> 31:28.630
and we have to specify the tolerations.

31:28.797 --> 31:31.321
Let's go here and do tolerations,

31:32.218 --> 31:33.612
taints and tolerations,

31:38.494 --> 31:40.753
or something like this, just any toleration.

31:43.209 --> 31:45.224
Specify the toleration.

31:48.613 --> 31:50.259
Let's add it at the end.

31:55.975 --> 31:57.590
I'll just fix the alignment.

32:02.050 --> 32:05.684
The key is, again, environment type,

32:06.766 --> 32:11.772
operator is equal, the value is production,

32:12.501 --> 32:13.941
and the effect is NoSchedule.

32:15.168 --> 32:17.197
That should be that.

32:17.905 --> 32:22.184
Save that and let's create that pod.

32:23.413 --> 32:27.250
Let's do a describe pod prod-redis

32:28.812 --> 32:32.370
and let's see it has

32:32.370 --> 32:33.692
tolerations environment type,

32:33.692 --> 32:34.989
production, and NoSchedule,

32:35.209 --> 32:38.215
and let's see which node it is assigned to.

32:38.215 --> 32:39.917
It's assigned to node01.

32:40.894 --> 32:42.271
You can get a better view

32:42.271 --> 32:44.940
if you run the get pods -o wide.

32:45.389 --> 32:48.814
We see that we have the prod-redis

32:49.124 --> 32:50.567
and the schedule on node01.

32:50.926 --> 32:53.006
That seems to be good.

32:54.749 --> 32:56.848
The next one is to create a pod

32:56.848 --> 32:59.056
called hr-pod in the hr namespace

32:59.238 --> 33:00.581
belonging to the production,

33:00.581 --> 33:03.095
environment, and frontend tier.

33:03.689 --> 33:06.659
There's label, the hr-pod has to be labeled

33:06.659 --> 33:08.004
environment=production

33:08.004 --> 33:09.309
and tier=frontend,

33:09.512 --> 33:11.466
and the image to use is redis:alpine.

33:12.140 --> 33:13.544
That's pretty straightforward.

33:14.569 --> 33:16.363
First, let's look at the pods

33:16.363 --> 33:18.720
in the hr namespace, the -hr.

33:19.762 --> 33:21.221
It says no resource was found

33:21.221 --> 33:22.353
in the hr namespace.

33:22.400 --> 33:25.076
Let's do a get namespaces.

33:25.801 --> 33:30.210
We see that there are no namespaces by hr,

33:30.210 --> 33:31.435
so that's something we have to do first.

33:31.435 --> 33:34.215
Let's create a namespace

33:35.120 --> 33:37.900
called hr first, so that's the first step.

33:38.247 --> 33:39.723
Next is to create a pod,

33:39.723 --> 33:43.602
so we're going to do a kubectl run hr-pod,

33:45.684 --> 33:47.461
and in the hr namespace,

33:47.461 --> 33:49.209
so that's for the hr namespace,

33:49.420 --> 33:50.829
and belonging to the production,

33:50.829 --> 33:52.300
environment, and frontend tier,

33:52.533 --> 33:53.330
and those are labels.

33:53.330 --> 33:54.363
We're going to add

33:54.378 --> 33:59.141
labels=environment=production,

34:01.146 --> 34:03.238
tier=frontend.

34:03.789 --> 34:06.400
If you're not sure how labels work,

34:06.400 --> 34:07.927
you' could do a kubectl run

34:08.240 --> 34:11.168
and help and just make sure the labels

34:11.168 --> 34:12.729
are specified in the right format.

34:12.729 --> 34:16.184
You have kubectl run, pod name,

34:16.184 --> 34:18.237
the image name, and then you have labels.

34:18.627 --> 34:20.167
The labels are specified,

34:20.213 --> 34:23.144
comma-separated within quotes.

34:23.253 --> 34:25.294
The quotes are not mandatory,

34:32.315 --> 34:33.924
but let's just put the quotes in.

34:37.309 --> 34:41.238
Oops, I missed the image again.

34:43.025 --> 34:46.601
Yes, image has to be redis:alpine.

34:47.890 --> 34:48.790
Specify that.

34:50.671 --> 34:53.762
Let's check the pod hr-pod

34:53.762 --> 34:55.120
in the hr namespace.

34:56.087 --> 34:58.157
We see the label set

34:58.157 --> 34:59.066
environment=production

34:59.066 --> 35:00.550
and tier=frontend.

35:02.012 --> 35:03.449
That should be good.

35:04.351 --> 35:06.591
The next one, question eight.

35:06.892 --> 35:10.080
A kubeconfig file called super.kubeconfig

35:10.080 --> 35:11.195
has been created under

35:11.195 --> 35:13.255
the root/CKA directory.

35:13.437 --> 35:16.969
You have root/CKA,

35:17.975 --> 35:20.516
and there is indeed a super.kubeconfig file.

35:20.538 --> 35:21.400
There's something wrong

35:21.400 --> 35:22.443
with the configuration,

35:22.443 --> 35:23.820
so troubleshoot and fix it.

35:24.581 --> 35:26.671
We know that we could do a kubectl,

35:27.944 --> 35:30.506
let's say, get nodes or any kind of command,

35:30.790 --> 35:32.976
and specify the kubeconfig file

35:32.976 --> 35:35.920
using the --kubeconfig option.

35:36.256 --> 35:38.341
We'll pass in a CKA.

35:38.341 --> 35:41.047
By default, the kubectl utility

35:41.047 --> 35:42.642
uses the kubeconfig file,

35:42.642 --> 35:44.688
which is under the .kube directory

35:46.116 --> 35:47.876
in the home directory of that user.

35:48.162 --> 35:49.197
In this case, we have to use

35:49.197 --> 35:50.446
another kubeconfig file,

35:50.446 --> 35:51.767
which is the super.kubeconfig file.

35:51.767 --> 35:52.843
For that, you could specify

35:52.843 --> 35:54.770
the --kubeconfig option.

35:54.904 --> 35:56.865
We have root/CKA

35:56.865 --> 35:59.141
and super.kubeconfig.

36:01.418 --> 36:02.928
When it's trying to connect

36:02.928 --> 36:03.975
to the server, it says,

36:03.975 --> 36:05.103
"The connection to the server

36:05.103 --> 36:07.393
controlplane 9999 was refused.

36:07.878 --> 36:09.842
Did you specify the right host or port?"

36:10.288 --> 36:11.675
If you look at it, of course,

36:11.675 --> 36:12.979
it looks like either the hostname

36:12.979 --> 36:13.847
or port is wrong.

36:13.847 --> 36:15.624
It looks like this port is wrong,

36:15.624 --> 36:16.729
because this is not the port

36:16.729 --> 36:19.086
that the kube API server runs on.

36:19.418 --> 36:20.993
If you're not sure,

36:21.306 --> 36:23.003
we could actually look at this file.

36:25.093 --> 36:26.610
If you look at the file,

36:26.610 --> 36:28.564
you'll see it has the API version,

36:28.564 --> 36:29.687
the cluster details.

36:30.036 --> 36:32.320
Here, you have the server, and it says,

36:32.484 --> 36:34.678
"Controlplane 9999."

36:34.773 --> 36:35.750
That seems to be wrong.

36:36.002 --> 36:37.311
We're not sure what the port--

36:37.517 --> 36:42.096
You could look at the current kubeconfig file,

36:44.184 --> 36:46.143
.kube/config.

36:47.505 --> 36:51.107
You'll see the port is 6443.

36:51.760 --> 36:53.604
That's the port that it should run on.

36:53.619 --> 36:55.192
Let's go ahead and fix it.

36:57.602 --> 37:03.323
/root/CKA/super.kubeconfig.

37:04.746 --> 37:06.237
Here, we have--

37:09.098 --> 37:10.276
Instead of 999,

37:10.276 --> 37:12.341
we're going to change it to 6443.

37:15.694 --> 37:17.103
Let's test.

37:18.426 --> 37:21.270
Let's test our work again using this command,

37:21.270 --> 37:23.583
get nodes with the custom kubeconfig file.

37:24.547 --> 37:25.912
That seems to be working.

37:28.329 --> 37:30.191
Let's go to the final question.

37:30.191 --> 37:31.878
We have created a new deployment

37:31.878 --> 37:32.882
called nginx-deploy.

37:32.882 --> 37:34.656
Scale the deployment to three replicas.

37:36.063 --> 37:37.280
Let's take a look at that.

37:37.280 --> 37:39.209
Let's do a kubectl get deploy.

37:39.408 --> 37:41.095
We see that there is a deployment

37:41.095 --> 37:42.351
called nginx-deploy.

37:45.704 --> 37:47.629
Then what we need to do

37:47.629 --> 37:48.504
is we need to scale it up,

37:48.504 --> 37:50.630
so let's do a kubectl scale

37:50.778 --> 37:53.650
deploy nginx-deploy

37:53.980 --> 37:59.636
and specify replicas to be three.

38:05.313 --> 38:07.464
Let's run a kubectl get deploy.

38:07.510 --> 38:10.860
We see it's one out of three ready,

38:11.883 --> 38:15.801
so let's take a look at the deployment

38:15.801 --> 38:16.865
in more detail.

38:16.865 --> 38:19.772
We expect it to be three out of three ready.

38:20.603 --> 38:21.743
As you can see here,

38:23.767 --> 38:26.686
it scaled up the replica set to one.

38:27.270 --> 38:29.141
We currently expect it to scale it up

38:29.141 --> 38:30.913
to three but that's not happening.

38:30.913 --> 38:32.715
That means that has not been initiated.

38:32.979 --> 38:36.256
We know that the deployment,

38:36.814 --> 38:38.341
or any kind of controllers,

38:38.341 --> 38:39.042
are managed by

38:39.042 --> 38:40.610
the kube-controller-manager.

38:40.938 --> 38:42.227
Let's take a look at--

38:42.283 --> 38:44.145
Only if the kube-controller-manager

38:44.145 --> 38:45.507
is not functioning properly,

38:46.201 --> 38:46.981
this can happen.

38:46.981 --> 38:51.631
Let's take a look at the pods system.

38:52.007 --> 38:52.841
We see that there is the

38:52.841 --> 38:53.900
kube-controller-manager

38:53.900 --> 38:55.912
indeed has some issue,

38:56.189 --> 38:57.658
so we're going to take a look at--

39:00.089 --> 39:04.676
Let's take a closer look at that pod.

39:07.815 --> 39:10.555
We see that it's failed to create a pod.

39:11.270 --> 39:12.649
It's an error response.

39:12.785 --> 39:15.413
There's also ImagePullBackOff error,

39:15.430 --> 39:18.642
so this image isn't right.

39:20.356 --> 39:21.781
There seems to be something wrong

39:21.781 --> 39:22.596
with the image.

39:24.414 --> 39:25.515
If you take a closer look,

39:25.515 --> 39:27.301
you'll see that there's a 1

39:27.301 --> 39:28.967
instead of an L here,

39:29.735 --> 39:31.347
as it's supposed to be controller-manager

39:31.347 --> 39:35.200
but it is just contro1ler-manager,

39:35.200 --> 39:36.208
so that's wrong.

39:37.236 --> 39:39.444
The kube-controller-manager

39:39.520 --> 39:42.960
is run as a static pod

39:42.960 --> 39:45.095
because you can see the controlplane

39:45.095 --> 39:46.518
appended to the end of it.

39:48.972 --> 39:51.098
The manifest file for that is under

39:51.098 --> 39:53.408
etc/kubernetes/manifests

39:53.876 --> 39:56.918
and you have kube-controller-manager.

39:59.629 --> 40:02.688
We need to edit this file and fix that.

40:04.421 --> 40:06.906
If you look at this image--

40:06.996 --> 40:09.076
Let's take a look at the image--

40:10.802 --> 40:14.480
you see that you have the kube-contro1ler.

40:15.420 --> 40:16.880
You could search for that.

40:19.073 --> 40:22.409
Let's just search for contro1.

40:23.226 --> 40:26.746
If you see, there's also a typo here.

40:27.910 --> 40:32.201
There's a contro1 here instead of L.

40:33.740 --> 40:37.449
If you just keep searching,

40:37.544 --> 40:39.175
so you have contro1.

40:43.243 --> 40:44.516
If you keep searching,

40:44.676 --> 40:45.437
you can see that

40:45.650 --> 40:47.442
it's the same in multiple places,

40:47.490 --> 40:49.064
so that's the third occurrence.

40:49.456 --> 40:51.093
Then there's the fourth occurrence,

40:51.786 --> 40:57.738
and the name as well has contro1 in it.

40:58.610 --> 41:02.824
There's one, two, three, four, five.

41:02.824 --> 41:04.964
It's incorrect in five different places,

41:05.207 --> 41:06.693
so let's go ahead and fix that.

41:08.608 --> 41:14.656
That's L, and that's another one.

41:16.266 --> 41:17.912
That's another place,

41:18.540 --> 41:20.601
and then you also have it here.

41:22.378 --> 41:24.710
If you could just do a "replace all",

41:24.792 --> 41:25.745
then that works too.

41:25.798 --> 41:27.183
If you're familiar with just doing

41:27.183 --> 41:28.984
a "replace all" with SED,

41:28.984 --> 41:30.065
then that works too.

41:34.768 --> 41:35.888
Let's search again.

41:36.901 --> 41:38.610
There are no more instances,

41:38.889 --> 41:39.815
so that's good.

41:40.283 --> 41:41.301
Let's save it.

41:49.968 --> 41:51.944
We now see that it's in a running state.

41:55.636 --> 41:56.833
Let's check our deployment.

41:59.030 --> 42:00.618
It's still one of three,

42:00.618 --> 42:01.830
so let's give it some time.

42:08.984 --> 42:09.648
That's it.

42:10.506 --> 42:11.939
It's now three out of three,

42:12.526 --> 42:14.341
so that indicates the issue is fixed.

42:14.419 --> 42:14.829
All right.

42:14.829 --> 42:16.736
We're at the end of the mock exam.

42:16.736 --> 42:19.260
Let's test our work by ending the exam.

42:29.001 --> 42:34.955
That's 44%, 58%, 70%, 78%,

42:34.955 --> 42:36.608
enough to pass the exam,

42:36.950 --> 42:38.409
and it's 100%.

42:39.129 --> 42:41.376
Well, I hope that was helpful.

42:41.456 --> 42:42.666
Thank you for watching.

42:43.168 --> 42:45.760
I wish you all the best for your exam.

