Kubernetes Cluster에서는 특정 Application을 모든 Node에서 실행해야 하는 경우가 있습니다.
예를 들어 Node 상태를 수집하는 Monitoring Agent, Log 수집 Agent, Network Plugin 같은 Component는 특정 Pod 개수만 실행하는 것이 아니라 모든 Node에 하나씩 실행되어야 합니다.
Kubernetes에서는 이러한 요구사항을 해결하기 위해 DaemonSet 기능을 제공합니다.
DaemonSet은 Kubernetes Node마다 하나의 Pod를 자동으로 배포하고 관리하는 Controller입니다.
| 구성 요소 | 역할 |
|---|---|
| DaemonSet | Node별 Pod 관리 |
| Pod | Agent Application 실행 |
| Node | Pod 배포 대상 |
| Controller | 상태 유지 |
DaemonSet 구조를 이해하면 Kubernetes 환경에서 Monitoring, Logging, Network 관리 Component가 어떻게 동작하는지 이해할 수 있습니다.
Kubernetes DaemonSet이란 무엇인가?
DaemonSet은 Cluster의 모든 Node 또는 특정 Node에 Pod를 하나씩 실행하도록 관리하는 Kubernetes Resource입니다.
일반적인 Deployment는 Replica 개수를 기준으로 Pod를 관리하지만 DaemonSet은 Node 개수를 기준으로 Pod를 관리합니다.
예:
Cluster Node:
Node A
Node B
Node C
DaemonSet:
Agent Pod 생성
Node A → Agent Pod
Node B → Agent Pod
Node C → Agent Pod
각 Node마다 동일한 Pod가 실행됩니다.
Kubernetes DaemonSet이 필요한 이유
Kubernetes 운영 환경에서는 모든 Node에서 실행되어야 하는 System Application이 존재합니다.
대표 사례:
| Application | 목적 |
|---|---|
| Fluent Bit | Log 수집 |
| Node Exporter | Monitoring |
| CNI Plugin | Network 관리 |
| Security Agent | 보안 관리 |
이러한 Application은 특정 Node 하나에서만 실행하면 전체 Cluster 관리가 어렵습니다.
DaemonSet은 모든 Node에 자동 배포하여 운영 효율성을 높입니다.
Kubernetes DaemonSet과 Deployment 차이
DaemonSet과 Deployment는 Pod 관리 방식이 다릅니다.
| 구분 | DaemonSet | Deployment |
|---|---|---|
| 기준 | Node 개수 | Replica 개수 |
| 목적 | Node별 실행 | Application 배포 |
| Pod 위치 | 모든 Node | Scheduler 결정 |
| 사용 사례 | Agent, System 서비스 | Web Application |
목적에 맞는 Controller 선택이 중요합니다.
Kubernetes DaemonSet 동작 구조
DaemonSet Controller는 Node 상태를 확인하고 필요한 Pod를 생성합니다.
구조:
| 구성 요소 | 역할 |
|---|---|
| DaemonSet Controller | Pod 관리 |
| Node | 실행 위치 |
| Pod | Agent 실행 |
| Kubelet | Container 실행 |
동작 과정:
| 단계 | 내용 |
|---|---|
| 1단계 | DaemonSet 생성 |
| 2단계 | Node 목록 확인 |
| 3단계 | Node별 Pod 생성 |
| 4단계 | 새로운 Node 추가 감지 |
| 5단계 | 자동 Pod 배포 |
새로운 Node가 추가되어도 DaemonSet이 자동으로 Pod를 생성합니다.
Kubernetes DaemonSet Pod 배치 방식
일반적인 Pod는 Scheduler가 Node를 선택하지만 DaemonSet은 Node별 배포 목적에 맞게 동작합니다.
예:
Cluster:
Node 3개
DaemonSet:
Replica 3개 자동 생성
Node 수 증가:
Node 5개
↓
Pod 자동 증가
Node 개수에 따라 Pod 개수가 변경됩니다.
Kubernetes DaemonSet과 kube-proxy 관계
Kubernetes 내부 Network Component인 kube-proxy도 DaemonSet 형태로 실행됩니다.
구조:
Node A
↓
kube-proxy Pod
Node B
↓
kube-proxy Pod
Node C
↓
kube-proxy Pod
모든 Node에서 Network Routing 기능을 제공하기 위해 사용됩니다.
Kubernetes DaemonSet과 Logging Agent
Logging 시스템에서는 DaemonSet이 자주 사용됩니다.
구조:
Application Container
↓
Container Log
↓
Fluent Bit DaemonSet
↓
Elasticsearch
↓
Kibana
각 Node에서 실행되는 Fluent Bit이 Container Log를 수집합니다.
이를 통해 Cluster 전체 Log를 중앙 관리할 수 있습니다.
Kubernetes DaemonSet Node 선택
DaemonSet은 특정 Node에만 Pod를 실행하도록 설정할 수 있습니다.
사용 기능:
| 기능 | 설명 |
|---|---|
| Node Selector | 특정 Label Node 선택 |
| Node Affinity | 복잡한 조건 설정 |
| Toleration | Taint Node 접근 허용 |
예:
GPU Node:
AI Monitoring Agent 실행
Database Node:
Backup Agent 실행
Kubernetes DaemonSet Update 방식
DaemonSet도 Application 업데이트가 필요합니다.
대표 방식:
| 방식 | 설명 |
|---|---|
| RollingUpdate | 순차 업데이트 |
| OnDelete | 삭제 후 업데이트 |
RollingUpdate를 사용하면 서비스 영향을 최소화하면서 변경할 수 있습니다.
Kubernetes DaemonSet 활용 사례
DaemonSet은 Cluster 운영에 필요한 다양한 Agent에서 활용됩니다.
| 활용 사례 | 설명 |
|---|---|
| Log Collection | Node별 Log 수집 |
| Monitoring | System Metric 수집 |
| Network | CNI, kube-proxy 실행 |
| Security | 보안 Agent 운영 |
Production Kubernetes 환경에서 필수적으로 사용되는 Controller입니다.
Kubernetes DaemonSet 운영 시 고려사항
DaemonSet은 모든 Node에 실행되기 때문에 Resource 관리가 중요합니다.
| 항목 | 설명 |
|---|---|
| CPU 사용량 | Node Resource 영향 |
| Memory 제한 | 장애 방지 |
| Node Label | 배포 대상 관리 |
| Update 정책 | 안정적인 변경 |
불필요한 DaemonSet은 Cluster Resource를 낭비할 수 있습니다.
Kubernetes DaemonSet 장애 처리
DaemonSet Pod에 문제가 발생하면 Controller가 상태를 확인합니다.
과정:
Pod 장애 발생
↓
DaemonSet Controller 감지
↓
새로운 Pod 생성
↓
Node Agent 복구
자동 복구 구조를 제공합니다.
Kubernetes DaemonSet 장점
| 장점 | 설명 |
|---|---|
| 자동 배포 | Node별 Pod 생성 |
| 운영 자동화 | Agent 관리 편리 |
| 확장성 | Node 증가 대응 |
| 일관성 | 모든 Node 동일 환경 |
DaemonSet은 Kubernetes Cluster 운영 관리의 핵심 기능입니다.
자주 묻는 질문
DaemonSet과 Deployment 차이는 무엇인가요?
DaemonSet은 모든 Node에 Pod를 실행하는 목적이고 Deployment는 Application Replica 개수를 관리하는 목적입니다.
DaemonSet은 Scheduler를 사용하나요?
일반적으로 DaemonSet Controller가 Node별 Pod 배치를 관리하며 Kubernetes 버전에 따라 Scheduler와 함께 동작할 수 있습니다.
새로운 Node가 추가되면 어떻게 되나요?
DaemonSet Controller가 새로운 Node를 감지하고 자동으로 Pod를 생성합니다.
마무리
Kubernetes DaemonSet은 Cluster 모든 Node에 필요한 Pod를 자동 배포하고 관리하는 핵심 Controller입니다.
| 구성 요소 | 역할 |
|---|---|
| DaemonSet | Node별 Pod 관리 |
| Controller | 상태 유지 |
| Pod | Agent 실행 |
| Node | 배포 대상 |
DaemonSet 구조를 이해하면 Kubernetes 환경에서 Monitoring, Logging, Network, Security Agent가 어떻게 모든 Node에서 동작하는지 이해할 수 있습니다.
다음 글에서는 Kubernetes Resource 자동 확장 기능을 위한 Kubernetes Horizontal Pod Autoscaler(HPA) 완벽 가이드! Traffic 기반 Pod 자동 확장 구조 이해하기를 알아보겠습니다.