[Kubernetes] DaemonSet (데몬셋)

2023. 2. 13. 17:50·Cloud Engineering/Kubernetes ⚙️
목차
  1. 데몬셋 (Daemon Set)
  2. 데몬셋을 사용하는 경우
728x90

데몬셋 (Daemon Set)

데몬셋은 레플리카셋이나 레플리케이션 컨트롤러처럼 object controller의 한 종류로 pod들을 관리하는 컨트롤러이다. 

데몬셋은 Node Label 이 일치하는 노드들 에 pod 복제본이 각 1개씩 실행되도록 관리한다. 만약 Node Label에 대해서 따로 설정을 해주지 않는다면 기본적으로 control plane을 제외한 워커로드에서 pod가 1개씩 실행되도록 관리하는 컨트롤러이다. 

레플리카셋 또는 레플리케이션 컨트롤러와 차이점은 별도로 pod 복제본 수를 제어하지 않는다는 점이다. 즉, 처음에 생성한 pod에 문제가 생겨서 삭제가 되면 레플리카셋이나 레플리케이션 컨트롤러는 복제본 pod을 스스로 생성해 준다. 그렇지만 데몬셋은 pod이 삭제가 되더어도 다시 pod을 생성하지 않는다. 데몬셋은 복제본 수를 제어하는 컨트롤러가 아니기 때문이다. 

 

데몬셋을 사용하는 경우

  • 각 노드들에서 로그들을 수집하는 경우
  • 클러스터 스토리지를 각 노드들에서 운영하는 경우 
  • 각각의 노드들을 모니터링하려는 경우 

 

데몬셋의 노드 레이블을 따로 지정하지 않은 경우 

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: example-ds
spec:
  selector:
    matchLabels:
      app: example-ds
  template:
    metadata:
      labels:
        app: example-ds
    spec:
      containers:
      - name: example
        image: httpd:2.4
        ports:
        - containerPort: 80
          protocol: TCP

노드 1, 2, 3 에서 각각 pod이 하나씩 실행되고 있는 것을 확인할 수 있다. 

vagrant@kube-control1:~/work/20230213$ kubectl get pods -o wide
NAME               READY   STATUS    RESTARTS   AGE   IP                NODE         NOMINATED NODE   READINESS GATES
example-ds-85pqx   1/1     Running   0          14s   192.168.119.145   kube-node3   <none>           <none>
example-ds-qcm8l   1/1     Running   0          14s   192.168.233.218   kube-node2   <none>           <none>
example-ds-qg785   1/1     Running   0          14s   192.168.9.92      kube-node1   <none>           <none>

 

Node Label을 지정하는 경우 

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: myapp-ds
spec:
  selector:
    matchLabels:
      app: myapp-ds
  template:
    metadata:
      labels:
        app: myapp-ds
    spec:
      nodeSelector:
        node: development
      containers:
      - name: myapp
        image: ghcr.io/c1t1d0s7/go-myweb:alpine
        ports:
        - containerPort: 8080
          protocol: TCP

pod template 의 하위에 있는 spec 필드에서 nodeSelector를 key: value 형태로 지정해주었다. key는 node이고 value는 development가 된다. node들 중에서 node=development 라는 라벨이 있는 node들만 데몬셋에 의해서 pod이 할당될 것이다. 

kubectl get nodes --show-labels 명령어로 현재 노드들의 레이블을 확인한다. 

vagrant@kube-control1:~/work/20230213$ kubectl get nodes --show-labels
NAME            STATUS   ROLES                  AGE     VERSION    LABELS
kube-control1   Ready    control-plane,master   4d20h   v1.22.10   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=kube-control1,kubernetes.io/os=linux,node-role.kubernetes.io/control-plane=,node-role.kubernetes.io/master=,node.kubernetes.io/exclude-from-external-load-balancers=
kube-node1      Ready    <none>                 4d20h   v1.22.10   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=kube-node1,kubernetes.io/os=linux
kube-node2      Ready    <none>                 4d20h   v1.22.10   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=kube-node2,kubernetes.io/os=linux
kube-node3      Ready    <none>                 4d20h   v1.22.10   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=kube-node3,kubernetes.io/os=linux

 

 node=development  레이블을 가진 노드는 현재 없으므로 pod도 생성되지 않는 것이다. 

$kubectl get daemonsets DAEMONSET 명령어로 현재 데몬셋의 목록을 확인한다. 

vagrant@kube-control1:~/work/20230213$ kubectl get daemonsets myapp-ds
NAME       DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR      AGE
myapp-ds   0         0         0       0            0           node=development   10s

 

pod을 할당받고 싶으면 할당받을 Node 에 지정한 노드 레이블을 추가해 주면 된다. 

$kubectl label nodes NODE KEY:VALUE

 

참고 문서 


https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/

 

DaemonSet

A DaemonSet ensures that all (or some) Nodes run a copy of a Pod. As nodes are added to the cluster, Pods are added to them. As nodes are removed from the cluster, those Pods are garbage collected. Deleting a DaemonSet will clean up the Pods it created. So

kubernetes.io

 

728x90

'Cloud Engineering > Kubernetes ⚙️' 카테고리의 다른 글

[Kubernetes] Service 의 종류  (0) 2023.02.16
[Kubernetes] Jobs (잡)과 CronJob  (0) 2023.02.13
[Kubernetes] Replication Controller (레플리케이션 컨트롤러)  (0) 2023.02.11
[Kubernetes] 컨테이너 프로브 (Container Probe)  (0) 2023.02.11
[Kubernetes] Pod Lifecycle (Pod의 생명주기) 와 컨테이너의 상태  (0) 2023.02.11
  1. 데몬셋 (Daemon Set)
  2. 데몬셋을 사용하는 경우
'Cloud Engineering/Kubernetes ⚙️' 카테고리의 다른 글
  • [Kubernetes] Service 의 종류
  • [Kubernetes] Jobs (잡)과 CronJob
  • [Kubernetes] Replication Controller (레플리케이션 컨트롤러)
  • [Kubernetes] 컨테이너 프로브 (Container Probe)
minjiwoo
minjiwoo
Data Engineering과 Cloud Native 기술에 대해 Dive Deep 하는 플랫폼 엔지니어가 되는 것을 목표로 하고 있습니다. 경험과 공부한 내용을 기록하며 지속가능한 엔지니어가 되는 것이 꿈입니다.
minjiwoo
minji's engineering note
minjiwoo
전체
오늘
어제
  • 분류 전체보기 (612)
    • Data Engineering (42)
      • Apache Spark (11)
      • Databricks & Delta Lake (9)
      • Airflow (3)
      • SQL (6)
      • Trouble Shooting (2)
      • Hadoop (2)
      • MLOps (1)
    • Cloud Engineering (104)
      • AWS (23)
      • Linux 🐧 (29)
      • Docker 🐳 (21)
      • Kubernetes ⚙️ (20)
      • Ansible (10)
    • Computer Science (87)
      • 네트워크 (9)
      • 운영체제 (25)
      • 정보처리기사 (48)
      • CS 기술 면접 스터디 (3)
    • Programming Languages (27)
      • Python (17)
      • C와 C++ (10)
    • Backend (5)
      • Django (2)
    • 프로젝트 (2)
      • 테크포임팩트 (2)
    • iOS (11)
      • 레이블러리 (2)
    • Algorithm (PS) (275)
      • LeetCode (6)
    • 개발일기 (29)
      • 내돈내산 후기🎮 (3)
      • 개발자 취준생 (4)
      • Today I Learned (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

  • Hi there

인기 글

태그

  • Kubernetes
  • Databricks
  • 프로그래머스
  • 쿠버네티스
  • AWS
  • 클라우드
  • 백준
  • 리눅스
  • 빅데이터
  • 스파크
  • Swift
  • 카카오코딩테스트
  • dp
  • BFS
  • linux
  • 알고리즘
  • 데이터브릭스
  • EC2
  • 데이터엔지니어링
  • 코딩테스트
  • 운영체제
  • 백트래킹
  • python
  • SPARK
  • 파이썬
  • dfs
  • Leetcode
  • 데이터엔지니어
  • ansible
  • docker

최근 댓글

최근 글

hELLO· Designed By정상우.v4.5.2
minjiwoo
[Kubernetes] DaemonSet (데몬셋)
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.