Killer Shell CKA - DaemonSet HostPath Configurator

Jmnote (토론 | 기여)님의 2025년 10월 28일 (화) 18:55 판 (새 문서: ==개요== ;Killer Shell CKA - DaemonSet HostPath Configurator * https://killercoda.com/killer-shell-cka/scenario/daemonset-hostpath-configurator * 각 노드에 특정 파일을...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

Killer Shell CKA - DaemonSet HostPath Configurator

2 요구사항[ | ]

  • DaemonSet 이름: configurator
  • 네임스페이스: configurator
  • 컨테이너 이미지: bash
  • HostPath로 노드의 /configurator 디렉터리를 파드의 /mount에 마운트
  • 컨테이너 시작 시 다음 명령을 통해 노드 파일에 값 기록 후 대기
    • echo aba997ac-1c89-4d64 > /mount/config && sleep 1d
  • 노드에 테인트 없음(톨러레이션 불필요)

3 구현[ | ]

1) DaemonSet 매니페스트 작성

controlplane:~$ vim ds-configurator.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: configurator
  namespace: configurator
  labels:
    k8s-app: configurator
spec:
  selector:
    matchLabels:
      name: configurator
  template:
    metadata:
      labels:
        name: configurator
    spec:
      containers:
      - name: configurator
        image: bash
        command:
          - sh
          - -c
          - 'echo aba997ac-1c89-4d64 > /mount/config && sleep 1d'
        volumeMounts:
        - name: vol
          mountPath: /mount
      volumes:
      - name: vol
        hostPath:
          path: /configurator

2) 적용

controlplane:~$ kubectl apply -f ds-configurator.yaml
daemonset.apps/configurator created

4 검증[ | ]

1) DaemonSet과 파드 상태 확인

controlplane:~$ kubectl -n configurator get ds,pod -o wide
NAME                          DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE   CONTAINERS     IMAGES   SELECTOR
daemonset.apps/configurator   2         2         2       2            2           <none>          28s   configurator   bash     name=configurator

NAME                     READY   STATUS    RESTARTS   AGE   IP            NODE           NOMINATED NODE   READINESS GATES
pod/configurator-5c9kh   1/1     Running   0          28s   192.168.1.4   node01         <none>           <none>
pod/configurator-xj8fg   1/1     Running   0          28s   192.168.0.4   controlplane   <none>           <none>

2) 노드 파일 내용 확인

  • 시나리오 검증 커맨드
controlplane:~$ ssh controlplane -- cat /configurator/config | grep aba997ac-1c89-4d64
aba997ac-1c89-4d64

controlplane:~$ ssh node01 -- cat /configurator/config | grep aba997ac-1c89-4d64
aba997ac-1c89-4d64

5 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}