본문 바로가기
Certification/CKAD

문제 1: 가장 기본적인 Pod 작성하기

by 인 체리 2025. 4. 10.

다음 조건을 만족하는 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에 대시 (-) 빼먹은 거 주의