All Articles

What is a DaemonSet in Kubernetes? Explained Simply (2026)

A DaemonSet ensures one pod runs on every node in your cluster. Here's what it is, how it works, and when to use it — explained simply with examples.

DevOpsBoysApr 14, 20264 min read
Share:Tweet

Some tools need to run on every node in your cluster — log collectors, monitoring agents, network plugins. You don't want to manually deploy them to each node. DaemonSet does this automatically.

The Problem DaemonSet Solves

Imagine you have a 10-node Kubernetes cluster and you need a log collector (like Fluent Bit) on every node to ship logs to Elasticsearch.

Without DaemonSet:

  • Deploy 10 pods manually, one per node
  • Add a new node → remember to deploy a pod on it
  • Remove a node → clean up the pod manually

With DaemonSet:

  • Define it once
  • Kubernetes automatically runs one pod on every node
  • New node added → pod automatically appears
  • Node removed → pod automatically cleaned up

What Is a DaemonSet?

A DaemonSet is a Kubernetes object that ensures exactly one pod runs on each node (or each node that matches a selector).

yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: log-collector
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: log-collector
  template:
    metadata:
      labels:
        app: log-collector
    spec:
      containers:
      - name: fluent-bit
        image: fluent/fluent-bit:2.2
        resources:
          requests:
            cpu: "100m"
            memory: "100Mi"
          limits:
            cpu: "200m"
            memory: "200Mi"
        volumeMounts:
        - name: varlog
          mountPath: /var/log
          readOnly: true
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
bash
kubectl apply -f daemonset.yaml
 
# One pod per node — automatically
kubectl get pods -n kube-system -l app=log-collector -o wide
# NAME                    NODE
# log-collector-abc12     node-1
# log-collector-def34     node-2
# log-collector-ghi56     node-3

How It Differs from a Deployment

DeploymentDaemonSet
ReplicasYou set a numberOne per node (automatic)
ScalingManual or HPAScales with nodes
Pod placementScheduler decidesOne on each node
Use caseStateless appsNode-level daemons
New nodeNo actionPod automatically created

A Deployment says "run 3 replicas anywhere." A DaemonSet says "run 1 pod on every node."


Real-World Use Cases

1. Log Collection

yaml
# Fluent Bit on every node → ships logs to Elasticsearch
- image: fluent/fluent-bit:2.2
  volumeMounts:
  - mountPath: /var/log        # read host's /var/log
    name: varlog

2. Monitoring / Metrics

yaml
# Prometheus Node Exporter — metrics from every node
- image: prom/node-exporter:v1.7.0
  ports:
  - containerPort: 9100
    hostPort: 9100       # accessible directly on node IP

3. Network Plugin (CNI)

Calico, Cilium, Flannel — all installed as DaemonSets. They configure networking on each node.

bash
# Cilium DaemonSet
kubectl get daemonset cilium -n kube-system

4. Storage Plugin (CSI)

Container Storage Interface drivers run as DaemonSets to mount volumes on each node.

5. Security Agent

Falco (runtime security) runs as a DaemonSet to monitor every node's syscalls.


Running Only on Specific Nodes

You don't always want the DaemonSet on every node. Use nodeSelector or nodeAffinity.

Node Selector

yaml
spec:
  template:
    spec:
      nodeSelector:
        node-type: gpu      # only on GPU nodes
bash
# Label a node
kubectl label node node-1 node-type=gpu
 
# DaemonSet pod will appear only on labeled nodes

Node Affinity (more flexible)

yaml
spec:
  template:
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/os
                operator: In
                values:
                - linux

DaemonSet vs System Nodes (tolerations)

By default, DaemonSets don't run on control plane (master) nodes because they have taints. To run on control plane too:

yaml
spec:
  template:
    spec:
      tolerations:
      - key: node-role.kubernetes.io/control-plane
        operator: Exists
        effect: NoSchedule

Updating a DaemonSet

Two update strategies:

RollingUpdate (default)

Updates pods one at a time:

yaml
spec:
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1    # update 1 pod at a time

OnDelete

Pods only update when manually deleted:

yaml
spec:
  updateStrategy:
    type: OnDelete
bash
# Trigger update
kubectl set image daemonset/log-collector fluent-bit=fluent/fluent-bit:2.3
 
# Check rollout
kubectl rollout status daemonset/log-collector -n kube-system

Useful Commands

bash
# List all DaemonSets in cluster
kubectl get daemonsets -A
 
# See which nodes have the pod
kubectl get pods -l app=log-collector -o wide
 
# Describe DaemonSet
kubectl describe daemonset log-collector -n kube-system
 
# How many pods should be running vs actually running
kubectl get daemonset log-collector -n kube-system
# NAME            DESIRED   CURRENT   READY   UP-TO-DATE
# log-collector   3         3         3       3
 
# Check DaemonSet pods on a specific node
kubectl get pods --field-selector spec.nodeName=node-1 -n kube-system

Summary

WhatDaemonSet
RunsOne pod per node
Scales withNumber of nodes
Used forLogging, monitoring, networking, security
Node selectorOptional — target specific nodes
Update strategyRollingUpdate or OnDelete

If your tool needs to be on every node and access node-level resources — DaemonSet is the answer. Don't manage per-node pods manually.


Learn More

Newsletter

Stay ahead of the curve

Get the latest DevOps, Kubernetes, AWS, and AI/ML guides delivered straight to your inbox. No spam — just practical engineering content.

Related Articles

Comments