Hey, in this video, we're going to walk through
the practice test for labels and selectors.
The question is we have deployed a number of PODs,
they are labelled with a tier, env and bu.
How many PODs exist in the dev environment?
We have to use selectors.
First, let's do a get PODs
and we see that there are a number of PODs.
Now we've got to filter it
and identify the PODs that are in the dev environment.
I'm assuming env is for environment.
That's the label and this is the key, and this is the value.
If we have to find PODs using the selector,
and then we'll say env equals dev.
We see that these are the PODs in the dev environment.
That's, one, two, three, four, five, six, seven.
Seven of them.
Now, let's say, since there are just seven,
it's easy for us to just count,
but let's say there are a lot of them
now where it becomes difficult to count mentally.
One thing you could do is just do a word count.
You could do a wc -l.
Now, the problem with this is this also counts this top line,
which is the header.
There is a way to print this without the headers,
and that's using the no headers option.
When you run that, you just get the output without the header,
then we can do a word count on that,
and that's seven.
Seven is the answer here.
The next question is, how many PODs are in the finance business unit?
We saw that
the label key is bu is for business unit,
and the business unit we are looking at finance.
We'll just use same command for this
and this time it's six.
How many objects are in the prod environment,
including PODs, ReplicaSets, and any other objects?
Let's use the same command
and change the labels.
The environment is prod
and now, we're only listing the PODs.
To list all objects,
what you can do is give all lists of PODs.
List all the objects in that namespace.
Here we have PODs, here we have service and we have ReplicaSets.
If you count this, let's do a word count.
That's number seven.
There are seven objects.
Then the next question is to identify the POD,
which is part of the prod environment, the finance BU,
and the front end tier, so one that has all of it.
The environment is prod,
then we can just add additional labels and separated by a comma.
BU equals finance
and tier is front end.
That happens to be this particular POD,
which starts with zzxdf, is this one right here.
The final question is about, again, labels.
There's a file called ReplicaSet definition file.
The request is to create the ReplicaSet,
but there's an issue with it, so we've got to fix it.
Let's try creating it.
It says the ReplicaSet is invalid.
Invalid value, selector does not match template labels.
Selector is this and template labels.
This is template and template labels is this.
The error message is that this does not match this.
We know that for ReplicaSet to manage the POD
so this is basically the POD definition.
The ReplicaSet needs to have these to match,
otherwise, it won't be able to manage the POD.
That's the validation error here.
We're going to fix this by changing this to the value below.
Save that,
and let's create the ReplicaSet,
and it's created.
Let's verify.
Patient.
Yes, that's working.
Okay, that's the end of this lab.