다음 조건을 만족하는 Pod YAML을 작성하시오:
- 이름: nginx-pod
- 컨테이너 이름: nginx-container
- 이미지: nginx:1.25
- 포트: 80
- 라벨: app=web
나의 답변
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
replicas: 1
selector:
matchLabels:
app: web
containers:
- name: nginx-container
image: nginx:1.25
ports:
containerPort: 80
수정 포인트
잘못된 부분
| replicas, selector | → Pod에는 없음! Deployment에만 있음 |
| ports 부분 | - containerPort: 80 로 리스트 형태여야 함 |
정답
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
app: web
spec:
containers:
- name: nginx-container
image: nginx:1.25
ports:
- containerPort: 80
- Pod는 replicas, selector 없음
- Deployment는 여러 개 관리 → replicas, selector 필요
- ports 아래 containerPort에 대시 (-) 빼먹은 거 주의
'Certification > CKAD' 카테고리의 다른 글
| 문제 5: Multi-Container Pod (0) | 2025.04.10 |
|---|---|
| 문제 4: configMap을 volume으로 마운트 (0) | 2025.04.10 |
| 문제 3: emptyDir Volume 사용 Pod (0) | 2025.04.10 |
| 문제 2: 환경변수 & 명령어 포함 Pod (0) | 2025.04.10 |
| Kubernetes with Docker Desktop for Windows 환경설정 (0) | 2025.03.18 |