티스토리 뷰

공부자료/CKA(K8S)

[CKA]따배씨 -08. NodeSelector

맥모닝프로 2026. 1. 1. 19:05

문제

  • 작업 클러스터: k8s
  • Schedule a pod as follows
    • Name: eshop-store
    • Image: nginx
    • Node Selector: disktype=ssd

문제 환경 구성

# 노드 레이블 추가
kubectl label nodes k8s-worker1 disktype=ssd
kubectl label nodes k8s-worker2 disktype=std

 

문제 풀이

# 1. 클러스터 context 변경
kubectl config use-context k8s

# 2. Pod 템플릿 생성
kubectl run eshop-store --image=nginx --dry-run=client -o yaml > eshop-store.yaml

# 3. nodeSelector 정보 추가
vim eshop-store.yaml

....
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: eshop-store
  name: eshop-store
spec:
  containers:
  - image: nginx
    name: eshop-store
  nodeSelector:
    disktype: ssd

# 4. pod 생성 및 확인
kubectl apply -f eshop-store.yaml
kubectl get pods -o wide |grep eshop-store
공지사항
최근에 올라온 글
최근에 달린 댓글
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
글 보관함