Practice Test - Labels and Selectors
- Take me to Practice Test
Solutions to Practice Test - Labels and Selectors
-
We have deployed a number of PODs. They are labelled with tier, env and bu. How many PODs exist in the dev environment (env)?
Here we are filtering pods by the value olf a label
kubectl get pods --selector env=devCount the pods (if any)
-
How many PODs are in the finance business unit (bu)?
Similarly …
kubectl get pods --selector bu=financeCount the pods (if any)
-
How many objects are in the prod environment including PODs, ReplicaSets and any other objects?
kubectl get all --selector env=prodCount everything (if anything)
-
Identify the POD which is part of the prod environment, the finance BU and of frontend tier?
We can combine label expressions with comma. Only items with all the given label/value pairs will be returned, i.e. it is an
andcondition.kubectl get all --selector env=prod,bu=finance,tier=frontend -
A ReplicaSet definition file is given replicaset-definition-1.yaml. Try to create the replicaset. There is an issue with the file. Try to fix it.
kubectl create -f replicaset-definition-1.yamlNote the error message.
Selector matchLabels should match with POD labels - Update
replicaset-definition-2.yamlThe values for labels on lines 9 and 13 should match.
$ kubectl create -f replicaset-definition-2.yaml