1. How many PODs exist on the system?
in the current(default) namespace
controlplane ~ ➜ k get pods
NAME READY STATUS RESTARTS AGE
webapp-color 1/1 Running 0 6m9s
answer : 1
2. What is the environment variable name set on the container in the pod?
controlplane ~ ➜ k describe pod webapp-color
Name: webapp-color
Namespace: default
Priority: 0
Service Account: default
Node: controlplane/192.26.255.3
Start Time: Fri, 05 Jul 2024 13:26:14 +0000
Labels: name=webapp-color
Annotations: <none>
Status: Running
IP: 10.42.0.9
IPs:
IP: 10.42.0.9
Containers:
webapp-color:
Container ID: containerd://3fa9d4221f9012aa56efdb33146ec5d6a36f997b0a86b967531e064ecd7da0d7
Image: kodekloud/webapp-color
Image ID: docker.io/kodekloud/webapp-color@sha256:99c3821ea49b89c7a22d3eebab5c2e1ec651452e7675af243485034a72eb1423
...
Environment:
APP_COLOR: pink
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-7xljf (ro)
Conditions:
answer : APP_COLOR
3. What is the value set on the environment variable APP_COLOR on the container in the pod?
answer : pink
4. View the web application UI by clicking on the Webapp Color Tab above your terminal.
This is located on the right side.
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.
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
name: webapp-color
name: webapp-color
spec:
containers:
- image: kodekloud/webapp-color
name: webapp-color
resources: {}
env:
- name: APP_COLOR
value: green
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
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.
7. How many ConfigMaps exists in the default namespace?
controlplane ~ ➜ k get configmaps
NAME DATA AGE
kube-root-ca.crt 1 30m
db-config 3 21s
answer : 2
8. Identify the database host from the config map db-config.
controlplane ~ ➜ k describe configmaps db-config
Name: db-config
Namespace: default
Labels: <none>
Annotations: <none>
Data
====
DB_HOST:
----
SQL01.example.com
DB_NAME:
----
SQL01
DB_PORT:
----
3306
BinaryData
====
Events: <none>
answer : SQL01.example.com
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 --help
Examples:
# Create a new config map named my-config with key1=config1 and key2=config2
kubectl create configmap my-config --from-literal=key1=config1
--from-literal=key2=config2
controlplane ~ ➜ k create configmap webapp-config-map --from-literal=APP_COLOR=darkblue --from-literal=APP_OTHER=disregard
10. Update the environment variable on the POD to use only the APP_COLOR key from the newly created ConfigMap.
Note: Delete and recreate the POD. Only make the necessary changes. Do not modify the name of the Pod.
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
name: webapp-color
name: webapp-color
spec:
containers:
- image: kodekloud/webapp-color
name: webapp-color
resources: {}
env:
- name: APP_COLOR
valueFrom:
configMapKeyRef:
name: webapp-config-map
key: APP_COLOR
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
11. 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.
'IT 기술 > k8s' 카테고리의 다른 글
[cka] Multi Container PODs (0) | 2024.07.05 |
---|---|
[cka] Secrets (0) | 2024.07.05 |
[cka] Rolling Updates and Rollbacks (0) | 2024.07.02 |
[cka] Managing Application Logs (0) | 2024.06.24 |
[cka] Monitor Cluster Components (0) | 2024.06.24 |
댓글