Skip to content

2.08 DaemonSets

🧩 DaemonSets in Kubernetes

  • DaemonSets are similar to ReplicaSets, but instead of managing replicas across nodes, they ensure one pod runs on every node in the cluster.
  • When a new node joins, a pod is automatically created on it; when a node is removed, the corresponding pod is deleted.
  • This guarantees one instance per node, maintaining consistent functionality across the cluster.

πŸ”Ή Use Cases

  • Deploying monitoring agents (e.g., Prometheus Node Exporter).
  • Running log collectors (e.g., Fluentd, Filebeat).
  • Installing node-level system daemons such as storage or networking agents.
  • Deploying networking components like Calico, which requires an agent on each node.
  • Running kube-proxy, which can be deployed as a DaemonSet to manage networking rules on all nodes.

πŸ”Ή Key Points

  • The DaemonSet manifest is almost identical to a ReplicaSet’s, except:
  • apiVersion β†’ apps/v1
  • kind β†’ DaemonSet
  • Includes a selector and template section with matching labels
  • To create and inspect a DaemonSet:
    kubectl create -f daemonset-definition.yaml
    kubectl get daemonsets
    kubectl describe daemonset <name>
    

Below is a sample YAML definition for a simple monitoring DaemonSet.

🧾 DaemonSet Example (Click to Expand)
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: monitoring-daemon
  labels:
    app: monitor-agent
spec:
  selector:
    matchLabels:
      app: monitor-agent
  template:
    metadata:
      labels:
        app: monitor-agent
    spec:
      containers:
        - name: node-monitor
          image: busybox
          imagePullPolicy: IfNotPresent
          command: ["sh", "-c", "while true; do echo 'Monitoring node...'; sleep 30; done"]
          resources:
            limits:
              cpu: "100m"
              memory: "128Mi"
            requests:
              cpu: "50m"
              memory: "64Mi"

πŸŽ₯ DaemonSets Video Tutorial

Watch this video to understand DaemonSets in Kubernetes more visually: