APPLICATION LIFECYCLE MANAGEMENT, PRACTICE TEST ENV VARIABLES
Application Lifecycle Management
1. How many PODs exist on the system? in the current(default) namespace
ask : 1
controlplane ~ ➜ kubectl get pod
NAME READY STATUS RESTARTS AGE
webapp-color 1/1 Running 0 24s
2. What is the environment variable name set on the container in the pod?
ask : APP_COLOR
kubectl describe pod webapp-color
Environment:
APP_COLOR: pink
3. What is the value set on the environment variable APP_COLOR on the container in the pod?
ask : pink
4. View the web application UI by clicking on the Webapp Color Tab above your terminal.
This is located on the right side.
05. 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
---
apiVersion: v1
kind: Pod
metadata:
labels:
name: webapp-color
name: webapp-color
namespace: default
spec:
containers:
- env:
- name: APP_COLOR
value: green
image: kodekloud/webapp-color
name: webapp-color
controlplane ~ ➜ kubectl get pod webapp-color -o yaml > webapp-test.yaml
controlplane ~ ➜ ls
sample.yaml webapp-test.yaml
controlplane ~ ➜ vi webapp-test.yaml
controlplane ~ ➜ kubectl delete pod webapp-color
pod "webapp-color" deleted
controlplane ~ ✖ kubectl apply -f webapp-test.yaml --force
pod/webapp-color created
06. 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.
Run the command kubectl get configmaps
controlplane ~ ➜ kubectl get configmaps
NAME DATA AGE
kube-root-ca.crt 1 26m
db-config 3 2m
Run the command kubectl describe configmaps and look for DB_HOST option
controlplane ~ ➜ kubectl describe configmaps db-config
Name: db-config
Namespace: default
Labels: <none>
Annotations: <none>
Data
====
DB_NAME:
----
SQL01
DB_PORT:
----
3306
DB_HOST:
----
SQL01.example.com
BinaryData
====
Events: <none>
controlplane ~ ➜
9. Create a new ConfigMap for the webapp-color POD. Use the spec given below.
- ConfigName Name: webapp-config-map
- Data: APP_COLOR=darkblue
kubectl create configmap webapp-config-map --from-literal=APP_COLOR=darkblue
Env
|
10. Update the environment variable on the POD to use the newly created ConfigMap
Note: Delete and recreate the POD. Only make the necessary changes. Do not modify the name of the Pod.
- Pod Name: webapp-color
- EnvFrom: webapp-config-map
Set the environment option to envFrom and use configMapRef webapp-config-map.
apiVersion: v1
data:
APP_COLOR: darkblue
kind: ConfigMap
metadata:
name: webapp-config-map
---
apiVersion: v1
kind: Pod
metadata:
labels:
name: webapp-color
name: webapp-color
namespace: default
spec:
containers:
- envFrom:
- configMapRef:
name: webapp-config-map
image: kodekloud/webapp-color
name: webapp-color
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.
Bookmark
https://kubernetes.io/docs/concepts/configuration/configmap/
'CKA (Certified Kubernetes Administrator) > Kode Kloud' 카테고리의 다른 글
4.Application Lifecycle Management - Multi Container PODs (0) | 2022.01.21 |
---|---|
4.Application Lifecycle Management - Secrets (0) | 2022.01.21 |
4.Application Lifecycle Management - Commands and Arguments (0) | 2022.01.20 |
4.Application Lifecycle Management - Rolling Updates and Rollbacks (0) | 2022.01.20 |
03.Logging & Monitoring - Managing Application Logs (0) | 2022.01.20 |