WEBVTT

00:01.070 --> 00:03.730
Hey, in this video,
we're going to walk through

00:03.730 --> 00:07.320
the practice test
for labels and selectors.

00:08.940 --> 00:11.660
The question is
we have deployed a number of PODs,

00:11.660 --> 00:17.100
they are labelled with a tier, env and bu.

00:17.220 --> 00:20.980
How many PODs exist
in the dev environment?

00:20.980 --> 00:22.650
We have to use selectors.

00:22.830 --> 00:26.770
First, let's do a get PODs

00:26.770 --> 00:29.880
and we see
that there are a number of PODs.

00:30.240 --> 00:31.890
Now we've got to filter it

00:31.890 --> 00:36.670
and identify the PODs
that are in the dev environment.

00:36.670 --> 00:39.450
I'm assuming env is for environment.

00:40.060 --> 00:44.050
That's the label and this is the key,
and this is the value.

00:44.190 --> 00:50.000
If we have to find PODs
using the selector,

00:50.380 --> 00:54.240
and then we'll say env equals dev.

00:56.140 --> 01:00.270
We see that these are the PODs
in the dev environment.

01:00.270 --> 01:03.460
That's, one, two, three,
four, five, six, seven.

01:03.460 --> 01:04.560
Seven of them.

01:06.660 --> 01:09.130
Now, let's say,
since there are just seven,

01:09.130 --> 01:11.250
it's easy for us to just count,

01:11.250 --> 01:13.730
but let's say there are a lot of them

01:13.730 --> 01:16.300
now where it becomes
difficult to count mentally.

01:16.300 --> 01:18.340
One thing you could do
is just do a word count.

01:18.340 --> 01:20.830
You could do a wc -l.

01:21.710 --> 01:25.320
Now, the problem with this is
this also counts this top line,

01:25.320 --> 01:26.590
which is the header.

01:27.730 --> 01:30.740
There is a way to print this
without the headers,

01:30.740 --> 01:34.880
and that's using the no headers option.

01:35.450 --> 01:39.040
When you run that, you just get
the output without the header,

01:39.040 --> 01:43.500
then we can do a word count on that,

01:43.500 --> 01:44.730
and that's seven.

01:44.730 --> 01:46.540
Seven is the answer here.

01:50.560 --> 01:55.360
The next question is, how many PODs
are in the finance business unit?

01:58.810 --> 02:00.270
We saw that

02:03.020 --> 02:08.800
the label key is bu is for business unit,

02:09.060 --> 02:11.870
and the business unit
we are looking at finance.

02:12.270 --> 02:15.640
We'll just use same command for this

02:15.950 --> 02:18.020
and this time it's six.

02:22.490 --> 02:25.560
How many objects
are in the prod environment,

02:25.560 --> 02:29.880
including PODs, ReplicaSets,
and any other objects?

02:30.810 --> 02:32.840
Let's use the same command

02:33.660 --> 02:37.280
and change the labels.

02:39.040 --> 02:44.960
The environment is prod

02:46.760 --> 02:50.730
and now, we're only listing the PODs.

02:51.460 --> 02:53.400
To list all objects,

02:53.780 --> 02:58.520
what you can do is give all lists of PODs.

02:59.330 --> 03:02.260
List all the objects in that namespace.

03:03.650 --> 03:07.290
Here we have PODs, here we have service
and we have ReplicaSets.

03:09.170 --> 03:12.350
If you count this, let's do a word count.

03:14.160 --> 03:15.450
That's number seven.

03:15.450 --> 03:17.280
There are seven objects.

03:21.000 --> 03:23.540
Then the next question
is to identify the POD,

03:23.540 --> 03:27.260
which is part of the prod environment,
the finance BU,

03:27.400 --> 03:32.170
and the front end tier,
so one that has all of it.

03:36.260 --> 03:37.730
The environment is prod,

03:37.730 --> 03:42.680
then we can just add additional labels
and separated by a comma.

03:43.000 --> 03:45.980
BU equals finance

03:46.440 --> 03:51.010
and tier is front end.

03:52.770 --> 03:57.180
That happens to be this particular POD,

03:57.290 --> 04:03.820
which starts with zzxdf,
is this one right here.

04:09.180 --> 04:12.720
The final question
is about, again, labels.

04:12.720 --> 04:16.810
There's a file called
ReplicaSet definition file.

04:17.800 --> 04:21.380
The request is to create the ReplicaSet,

04:21.380 --> 04:24.170
but there's an issue with it,
so we've got to fix it.

04:24.350 --> 04:26.090
Let's try creating it.

04:30.330 --> 04:33.540
It says the ReplicaSet is invalid.

04:33.840 --> 04:37.810
Invalid value,
selector does not match template labels.

04:37.950 --> 04:42.100
Selector is this and template labels.

04:42.100 --> 04:44.500
This is template
and template labels is this.

04:45.210 --> 04:48.300
The error message is that
this does not match this.

04:48.400 --> 04:51.390
We know that for ReplicaSet
to manage the POD

04:51.390 --> 04:53.500
so this is basically the POD definition.

04:53.500 --> 04:57.000
The ReplicaSet
needs to have these to match,

04:57.870 --> 05:00.650
otherwise, it won't be able
to manage the POD.

05:00.650 --> 05:01.960
That's the validation error here.

05:01.960 --> 05:08.000
We're going to fix this
by changing this to the value below.

05:08.990 --> 05:10.190
Save that,

05:10.830 --> 05:15.090
and let's create the ReplicaSet,

05:15.330 --> 05:16.980
and it's created.

05:17.090 --> 05:18.460
Let's verify.

05:22.770 --> 05:23.940
Patient.

05:24.740 --> 05:26.860
Yes, that's working.

05:28.720 --> 05:31.860
Okay, that's the end of this lab.

