다음 조건을 만족하는 Deployment YAML을 작성하시오:
- 이름: web-deploy
- 레플리카 수: 2
- 라벨: app=web, tier=frontend
- 컨테이너 이름: web-container
- 이미지: nginx:1.25
- 컨테이너 포트: 80
- 환경 변수 MODE, DEBUG는 ConfigMap web-config에서 가져올 것
- readinessProbe: HTTP GET /healthz, 포트 80, 초기 지연 5초, 주기 10초
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-deploy
spec:
replicas: 2
selector:
matchLabels:
app: web
tier: frontend
template:
metadata:
labels:
app: web
tier: frontend
spec:
containers:
- name: web-container
image: nginx:1.25
port:
containerPort: 80
env:
- name: MODE
valueFrom:
configMapKeyRef:
name: web-config
- name: DEBUG
valueFrom:
configMapKeyRef:
name: web-config
readinessProbe:
httpGet:
path: /healthz
port: 80
initialDelaySeconds: 5
periodSeconds: 10
부족한 부분
- port → ports
- configMapKeyRef에 key 누락!!
정답
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-deploy
spec:
replicas: 2
selector:
matchLabels:
app: web
tier: frontend
template:
metadata:
labels:
app: web
tier: frontend
spec:
containers:
- name: web-container
image: nginx:1.25
ports:
- containerPort: 80
env:
- name: MODE
valueFrom:
configMapKeyRef:
name: web-config
key: MODE
- name: DEBUG
valueFrom:
configMapKeyRef:
name: web-config
key: DEBUG
readinessProbe:
httpGet:
path: /healthz
port: 80
initialDelaySeconds: 5
periodSeconds: 10'Certification > CKAD' 카테고리의 다른 글
| 미션: All-in-One Pod (0) | 2025.04.11 |
|---|---|
| 문제 7: Secret + LivenessProbe (0) | 2025.04.10 |
| 문제 5: Multi-Container Pod (0) | 2025.04.10 |
| 문제 4: configMap을 volume으로 마운트 (0) | 2025.04.10 |
| 문제 3: emptyDir Volume 사용 Pod (0) | 2025.04.10 |