문제1
How many PODs exist on the system?
In the current(default) namespace
풀이
controlplane ~ ➜ k get po
NAME READY STATUS RESTARTS AGE
webapp-color 1/1 Running 0 2m48s
문제2
What is the environment variable name set on the container in the pod?
풀이
controlplane ~ ➜ k get po webapp-color -o jsonpath='{..env}'
[{"name":"APP_COLOR","value":"pink"}]
문제3
What is the value set on the environment variable APP_COLOR on the container in the pod?
풀이
controlplane ~ ➜ k get po webapp-color -o jsonpath='{..env}'
[{"name":"APP_COLOR","value":"pink"}]
문제4
View the web application UI by clicking on the Webapp Color Tab above your terminal.
This is located on the right side.
풀이
- UI만 확인 해주었음
문제5
Update the environment variable on the POD to display a green background.
Note: Delete and recreate the POD. Only make the necessary changes. Do not modify the name of the Pod.
Pod Name: webapp-color
Label Name: webapp-color
Env: APP_COLOR=green
풀이
- 기존에 만들어 놓은 파드를 yaml로 추출해서 지울거 지우고 env만 수정함
apiVersion: v1
kind: Pod
metadata:
labels:
name: webapp-color
name: webapp-color
spec:
containers:
- env:
- name: APP_COLOR
value: green
image: kodekloud/webapp-color
imagePullPolicy: Always
name: webapp-color
문제6
View the changes to the web application UI by clicking on the Webapp Color Tab above your terminal.
If you already have it open, simply refresh the browser.
풀이
- UI 화면이 초록색으로 변경됨
문제7
How many ConfigMaps exists in the default namespace?
풀이
controlplane ~ ➜ k get cm
NAME DATA AGE
kube-root-ca.crt 1 23m
db-config 3 10s
문제8
Identify the database host from the config map db-config.
풀이
controlplane ~ ➜ k get cm db-config -o yaml
apiVersion: v1
data:
DB_HOST: SQL01.example.com
DB_NAME: SQL01
DB_PORT: "3306"
kind: ConfigMap
metadata:
creationTimestamp: "2024-01-01T06:33:36Z"
name: db-config
namespace: default
resourceVersion: "1062"
uid: a8f4fa92-a32d-4de2-a808-1cbcb7ed6af1
문제9
Create a new ConfigMap for the webapp-color POD. Use the spec given below.
ConfigMap Name: webapp-config-map
Data: APP_COLOR=darkblue
Data: APP_OTHER=disregard
풀이
controlplane ~ ➜ k create configmap webapp-config-map --from-literal=APP_COLOR=darkblue --from-literal=APP_OTHER=disregard
configmap/webapp-config-map created
문제10
Update the environment variable on the POD to use only the APP_COLOR key from the newly created ConfigMap.
Pod Name: webapp-color
ConfigMap Name: webapp-config-map
풀이
apiVersion: v1
kind: Pod
metadata:
labels:
name: webapp-color
name: webapp-color
spec:
containers:
- env:
- name: APP_COLOR
valueFrom:
configMapKeyRef:
name: webapp-config-map
key: APP_COLOR
image: kodekloud/webapp-color
imagePullPolicy: Always
name: webapp-color
- 아까 생성했던 pod yaml 파일에서 configMapKeyRef를 이용해 key 기반으로 변수를 가져올수 있도록 해줌
- 대소문자 및 depth에 유의해야 할듯
'자격증 > Kubernetes CKA' 카테고리의 다른 글
[CKA] 명령어 정리 - 2 (1) | 2024.01.02 |
---|---|
[CKA] 명령어 정리 - 1 (1) | 2024.01.02 |
[CKA] Practice Test - Commands And Arguments (1) | 2024.01.01 |
[CKA] Troubleshooting (0) | 2023.12.31 |
[CKA] Install "Kubernetes the kubeadm way" (0) | 2023.12.31 |