☁️ Cloud

DaemonSet

Kubernetes DaemonSet

A Kubernetes resource that runs a Pod on every node. Used for log collection and monitoring agents.

📖 Detailed Explanation

A DaemonSet is a workload resource that ensures exactly one Pod replica runs on every node (or selected nodes) of a Kubernetes cluster. When a new node is added to the cluster, a Pod is automatically created on that node, and when a node is removed, its Pod is cleaned up along with it.

In traditional server environments, agents were installed manually on each host, or configuration management tools such as Ansible were used. DaemonSet implements this "one process per node" pattern in a Kubernetes-native way, providing the benefits of declarative management and automatic scaling.

A DaemonSet does not go through kube-scheduler; the DaemonSet controller assigns Pods to nodes directly. For this reason, it is well suited to system components that must run before other workloads (such as CNI and CSI plugins). In addition, Pods can be deployed only to specific node groups through nodeSelector, nodeAffinity, and tolerations.

In practice, DaemonSet is widely used for core cluster infrastructure components such as log collectors (Fluentd, Fluent Bit), metrics collectors (Node Exporter, Datadog Agent), network plugins (Calico, Cilium), storage drivers, and security agents (Falco).

💻 Code Example

# Fluent Bit 로그 수집 DaemonSet 예제
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluent-bit
  namespace: logging
  labels:
    app: fluent-bit
spec:
  selector:
    matchLabels:
      app: fluent-bit
  template:
    metadata:
      labels:
        app: fluent-bit
    spec:
      serviceAccountName: fluent-bit
      containers:
      - name: fluent-bit
        image: fluent/fluent-bit:2.2
        ports:
        - containerPort: 2020
          name: metrics
        volumeMounts:
        - name: varlog
          mountPath: /var/log
          readOnly: true
        - name: containers
          mountPath: /var/lib/docker/containers
          readOnly: true
        - name: config
          mountPath: /fluent-bit/etc/
        resources:
          requests:
            cpu: 50m
            memory: 64Mi
          limits:
            cpu: 200m
            memory: 128Mi
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: containers
        hostPath:
          path: /var/lib/docker/containers
      - name: config
        configMap:
          name: fluent-bit-config
      tolerations:
      - operator: Exists  # 모든 taint 허용

🗣️ Say It Like This in Practice

💬 In a Meeting
"We need to collect logs from every node, so let's deploy Fluent Bit as a DaemonSet. If you put Exists in tolerations, it will also run on tainted nodes, so we won't miss logs from GPU nodes or ingress-only nodes."
💬 In an Interview
"As for the difference between a DaemonSet and a Deployment, a Deployment creates as many Pods as the number of replicas, and the scheduler decides node placement. A DaemonSet, on the other hand, guarantees exactly one Pod per node, and the number of Pods is adjusted automatically as nodes are added or removed."
💬 During Incident Response
"When we looked into why the DaemonSet Pod wasn't starting on a particular node, it turned out the node had a taint and the DaemonSet had no matching tolerations. The Node Exporter was missing, so that node's metrics were not being collected."

Take a mock interview on this topic → WIA SOOM AI Interview · Start for free

⚠️ Common Mistakes & Cautions

❌
tolerations Not Set

By default, a DaemonSet also avoids taints. Pods are not deployed to master/control-plane nodes or dedicated node pools, which causes missing logs/metrics. Be sure to add appropriate tolerations to system DaemonSets.

❌
Resource Requests Not Set

DaemonSet Pods also consume resources. If requests are not set, they are not included in per-node resource planning, so resource shortages can occur when actual workloads are deployed. In particular, the more nodes there are, the larger the total resource usage becomes.

✅
The right approach

For system DaemonSets, set priorityClassName: system-node-critical so that they run ahead of other workloads, and set updateStrategy.rollingUpdate.maxUnavailable appropriately to maintain availability even during updates.

🔗 Related Terms

📚 Learn More