본문 바로가기

CKA &. CKAD/Scheduling

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' 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 

'CKA &. CKAD > Scheduling' 카테고리의 다른 글

Resource Limits  (0) 2021.03.26
Practice Test - Node Selectors/Affinity  (0) 2021.03.26
Practice Test - Taints and Tolerations  (0) 2021.03.26
Labels and Selectors  (0) 2021.03.25
Manual Scheduling  (0) 2021.03.25