πŸ“šBook Signing at KubeCon EU 2026Meet us at Booking.com HQ (Mon 18:30-21:00) & vCluster booth #521 (Tue 24 Mar, 12:30-1:30pm) β€” free book giveaway!RSVP Booking.com Event
Deployments intermediate ⏱ 15 minutes K8s 1.28+

Kubernetes DaemonSet Complete Guide

Deploy DaemonSets in Kubernetes to run one pod per node. Covers monitoring agents, log collectors, CNI plugins, node affinity, and rolling update strategies.

By Luca Berton β€’ β€’ πŸ“– 5 min read

πŸ’‘ Quick Answer: deployments

The Problem

This is one of the most searched Kubernetes topics with thousands of monthly searches. A comprehensive, production-ready guide prevents hours of trial and error.

The Solution

Create a DaemonSet

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-exporter
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app: node-exporter
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1      # Update 1 node at a time
  template:
    metadata:
      labels:
        app: node-exporter
    spec:
      tolerations:
        # Run on ALL nodes including control plane
        - operator: Exists
      hostNetwork: true       # Access node network
      hostPID: true           # Access node processes
      containers:
        - name: node-exporter
          image: prom/node-exporter:v1.7.0
          ports:
            - containerPort: 9100
              hostPort: 9100
          resources:
            requests:
              cpu: 50m
              memory: 64Mi
            limits:
              cpu: 200m
              memory: 128Mi
          volumeMounts:
            - name: proc
              mountPath: /host/proc
              readOnly: true
            - name: sys
              mountPath: /host/sys
              readOnly: true
      volumes:
        - name: proc
          hostPath:
            path: /proc
        - name: sys
          hostPath:
            path: /sys

Target Specific Nodes

spec:
  template:
    spec:
      # Only run on GPU nodes
      nodeSelector:
        accelerator: nvidia-gpu
      # Or use affinity for more control
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: node-role.kubernetes.io/worker
                    operator: Exists

Common DaemonSet Use Cases

Use CaseExample
MonitoringPrometheus node-exporter, Datadog agent
LoggingFluent Bit, Fluentd, Filebeat
NetworkingCalico, Cilium, kube-proxy
StorageCSI node plugins, Longhorn
SecurityFalco, Twistlock defenders
# Check DaemonSet status
kubectl get ds -n monitoring
# NAME            DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE
# node-exporter   5         5         5       5            5

kubectl rollout status ds/node-exporter -n monitoring
graph TD
    A[DaemonSet: node-exporter] --> B[worker-1: node-exporter pod]
    A --> C[worker-2: node-exporter pod]
    A --> D[worker-3: node-exporter pod]
    E[New node added] -->|Auto-scheduled| F[worker-4: node-exporter pod]
    G[Node removed] -->|Auto-cleaned| H[Pod terminated]

Frequently Asked Questions

DaemonSet vs Deployment with anti-affinity?

DaemonSet guarantees exactly one pod per matching node, auto-scales with node count, and respects node selectors. Using Deployment + anti-affinity is a hack β€” use DaemonSets for per-node workloads.

How to skip certain nodes?

Use nodeSelector or nodeAffinity to target specific nodes. Or add taints to nodes you want to skip and don’t include matching tolerations in the DaemonSet.

Best Practices

  • Start with the simplest configuration that solves your problem
  • Test in staging before production
  • Use kubectl describe and events for troubleshooting
  • Document team conventions for consistency

Key Takeaways

  • This is fundamental Kubernetes operational knowledge
  • Follow established conventions and recommended labels
  • Monitor and iterate based on real production behavior
  • Automate repetitive tasks to reduce human error
#daemonset #per-node #monitoring #logging #kubernetes
Luca Berton
Written by Luca Berton

Principal Solutions Architect specializing in Kubernetes, AI/GPU infrastructure, and cloud-native platforms. Author of Kubernetes Recipes and creator of CopyPasteLearn courses.

Kubernetes Recipes book cover

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens