티스토리 뷰

문제

  • Set configuration context: kubectl config use-context k8s
  • Expose Configuration settings
    • Task:
      1. All operations in this question should be performed in the ckad namespace.
      2. Create a ConfigMap called web-config that contains the following two entries:
        • connection_string=localhost:80
        • external_url=cncf.io
      3. . Run a pod called web-pod with a single container running the nginx:1.19.8-alpine image, and expose these configuration settings as environment variables inside the container."

문제 풀이

# 1. Context 변경
kubectl config use-context k8s



# 2.네임 스페이스 확인(미존재시 생성)
kubectl get namespaces ckad
kubectl create namespace ckad

# 3. ConfigMap 생성
kubectl create configmap web-config --from-literal=connection_string=localhost:80 --from-literal external_url=cncf.io --namespace ckad
kubectl get configmaps web-config -n ckad -o yaml



# 4. web-pod yaml 파일 생성
kubectl run web-pod --image=nginx:1.19.8-alpine -o yaml --dry-run=client > web-pod.yaml

vim web-pod.yaml

....
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: web-pod
  name: web-pod
  namespace: ckad
spec:
  containers:
  - image: nginx:1.19.8-alpine
    name: web-pod
    envFrom:
      - configMapRef:
          name: web-config



# 5. web-pod 생성 및 env 확인
kubectl apply -f web-pod.yaml
kubectl exec -it -n ckad web-pod -- env
 

ConfigMaps

A ConfigMap is an API object used to store non-confidential data in key-value pairs. Pods can consume ConfigMaps as environment variables, command-line arguments, or as configuration files in a volume. A ConfigMap allows you to decouple environment-specifi

kubernetes.io

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/09   »
일 월 화 수 목 금 토
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함