CKA &. CKAD/Scheduling
Practice Test - Labels and Selectors
Clark Shim
2021. 3. 25. 23:51
ㅁ We have deployed a number of PODs. They are labelled with 'tier', 'env' and 'bu'. How many PODs exist in the 'dev' environmnet?
Use selectors to filter the output
kubectl get pods --show-labels
kubectl get pods --selector env=dev
or
kubectl get pods -l env=dev
or
kbuectl get pods -l env=dev --no-headers | wc -l
ㅁ How many PODs are in the "finance" business unit ("bu")"
kubectl get pods --selector bu=finance
ㅁ How many objects are in the "prod" environment including PODs, ReplicaSets and any other object?
kubectl get all --selector env=prod
ㅁ Identify the POD which is part of the prod environment, the finance BU and of frontend tier
kubectl get pods --selector env=prod,bu=finance,tier=frontend
ㅁ A ReplicaSet definition file is given "replicaset-defintion-1.yaml", Try to create the replicaset. There is an issue with the file. Try to fix it
이슈 있는 definition.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: replicaset-1
spec:
replicas: 2
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: nginx
spec:
containers:
- name: nginx
image: nginxcontrolplane
해결된 definition.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: replicaset-1
labels:
tier: frontend
spec:
replicas: 2
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: nginx
image: nginxcontrolplane