Skip to main content

DaemonSets:

 

DaemonSets: Running System Services on Every Node

📅 Published: August 2026
⏱️ Estimated Reading Time: 12 minutes
🏷️ Tags: Kubernetes, DaemonSets, System Services, Node Monitoring, DevOps


Introduction: What is a DaemonSet?

A DaemonSet is a Kubernetes controller that ensures a copy of a Pod runs on every node in your cluster. When you add a new node, the DaemonSet automatically deploys the Pod on that node. When you remove a node, the Pod is garbage collected.

Think of a DaemonSet as a "node daemon manager." It runs background services that need to be present on every node, such as monitoring agents, log collectors, or network proxies.

Key characteristics:

  • Runs one Pod per node: Exactly one Pod per eligible node

  • Auto-scaling: New nodes get the Pod automatically

  • Auto-healing: Pods are recreated if they fail

  • Node selection: Can run on specific nodes using nodeSelectors, tolerations, and affinities


Part 1: Why Use DaemonSets?

Common DaemonSet Use Cases

Monitoring and Observability:

  • Prometheus Node Exporter: Collects node metrics

  • Datadog Agent: Monitors applications and infrastructure

  • Fluentd/Fluent Bit: Collects and forwards logs

Networking:

  • Calico, Weave, Flannel: Network plugins for pod networking

  • Cilium: eBPF-based networking and security

Storage:

  • Ceph, GlusterFS: Distributed storage clients

  • CSI Drivers: Container Storage Interface drivers

Security:

  • Falco: Runtime security monitoring

  • AppArmor, SELinux: Security policy enforcement

System Management:

  • Node Problem Detector: Detects node issues

  • kube-proxy: Kubernetes network proxy


Part 2: DaemonSet vs Other Controllers

AspectDaemonSetDeploymentStatefulSetJob/CronJob
Pods per nodeExactly one (per node)Many (any node)Many (any node)One or many
Pod identityRandomRandomOrderedRandom
ScalingAuto with nodesManualManualManual
Use caseNode-level servicesStateless appsStateful appsBatch jobs

DaemonSet vs Deployment

text
Deployment:
Node 1: [Pod A] [Pod B]
Node 2: [Pod C]
Node 3: [Pod D] [Pod E] [Pod F]

DaemonSet:
Node 1: [Pod X]
Node 2: [Pod X]
Node 3: [Pod X]

Every node gets exactly one Pod from the DaemonSet.


Part 3: DaemonSet YAML Structure

Basic DaemonSet Example

yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd
  namespace: kube-system
  labels:
    app: fluentd
spec:
  selector:
    matchLabels:
      app: fluentd
  template:
    metadata:
      labels:
        app: fluentd
    spec:
      containers:
      - name: fluentd
        image: fluent/fluentd-kubernetes-daemonset:v1-debian-elasticsearch
        env:
        - name: FLUENT_ELASTICSEARCH_HOST
          value: "elasticsearch.logging.svc.cluster.local"
        - name: FLUENT_ELASTICSEARCH_PORT
          value: "9200"
        volumeMounts:
        - name: varlog
          mountPath: /var/log
        - name: dockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
      terminationGracePeriodSeconds: 30
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: dockercontainers
        hostPath:
          path: /var/lib/docker/containers

Node Selection with nodeSelector

yaml
spec:
  template:
    spec:
      nodeSelector:
        kubernetes.io/os: linux

Tolerations

yaml
spec:
  template:
    spec:
      tolerations:
      - key: node-role.kubernetes.io/master
        operator: Exists
        effect: NoSchedule
      - key: node.kubernetes.io/not-ready
        operator: Exists
        effect: NoExecute
        tolerationSeconds: 60

Updating a DaemonSet

yaml
spec:
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
yaml
spec:
  updateStrategy:
    type: OnDelete

Part 4: Real-World DaemonSet Examples

Example 1: Fluentd Log Collector

yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd
  namespace: logging
spec:
  selector:
    matchLabels:
      app: fluentd
  template:
    metadata:
      labels:
        app: fluentd
    spec:
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      containers:
      - name: fluentd
        image: fluent/fluentd-kubernetes-daemonset:v1-debian-elasticsearch
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
        - name: dockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
        env:
        - name: FLUENT_ELASTICSEARCH_HOST
          value: "elasticsearch.logging.svc.cluster.local"
        - name: FLUENT_ELASTICSEARCH_PORT
          value: "9200"
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: dockercontainers
        hostPath:
          path: /var/lib/docker/containers
      serviceAccountName: fluentd
      terminationGracePeriodSeconds: 30

Example 2: Prometheus Node Exporter

yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-exporter
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app: node-exporter
  template:
    metadata:
      labels:
        app: node-exporter
    spec:
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      hostNetwork: true
      hostPID: true
      containers:
      - name: node-exporter
        image: prom/node-exporter:v1.7.0
        args:
        - --path.procfs=/host/proc
        - --path.sysfs=/host/sys
        - --path.rootfs=/host/root
        ports:
        - name: metrics
          containerPort: 9100
          hostPort: 9100
        volumeMounts:
        - name: proc
          mountPath: /host/proc
          readOnly: true
        - name: sys
          mountPath: /host/sys
          readOnly: true
        - name: root
          mountPath: /host/root
          readOnly: true
      volumes:
      - name: proc
        hostPath:
          path: /proc
      - name: sys
        hostPath:
          path: /sys
      - name: root
        hostPath:
          path: /

Part 5: DaemonSet Commands

bash
# List DaemonSets
kubectl get daemonsets
kubectl get ds

# List DaemonSets in all namespaces
kubectl get ds --all-namespaces

# Describe a DaemonSet
kubectl describe daemonset fluentd

# Create a DaemonSet
kubectl apply -f fluentd-daemonset.yaml

# Update a DaemonSet
kubectl apply -f fluentd-daemonset.yaml

# Delete a DaemonSet
kubectl delete daemonset fluentd

# Scale a DaemonSet (if using nodeSelector to limit nodes)
# DaemonSets scale automatically with nodes

# Check DaemonSet status
kubectl rollout status ds/fluentd

Part 6: DaemonSet Best Practices

Resource Limits

Always set resource requests and limits for DaemonSet Pods to prevent them from consuming too many resources.

yaml
resources:
  requests:
    cpu: 100m
    memory: 100Mi
  limits:
    cpu: 200m
    memory: 200Mi

Tolerations

Use tolerations to run DaemonSets on control plane nodes:

yaml
tolerations:
- key: node-role.kubernetes.io/master
  operator: Exists
  effect: NoSchedule

Node Affinity

Use node affinity to target specific node types:

yaml
affinity:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
      - matchExpressions:
        - key: node-type
          operator: In
          values:
          - gpu

Update Strategy

Use rolling updates for zero-downtime updates:

yaml
updateStrategy:
  type: RollingUpdate
  rollingUpdate:
    maxUnavailable: 1

Priority Class

Set priority class to ensure DaemonSet Pods are scheduled:

yaml
priorityClassName: system-node-critical

Part 7: DaemonSet Troubleshooting

Pod Not Running

bash
# Check DaemonSet status
kubectl get ds fluentd

# Check Pod status
kubectl get pods -l app=fluentd

# Check Pod logs
kubectl logs fluentd-abc123

# Check Pod events
kubectl describe pod fluentd-abc123

Common Issues

IssueSolution
Node not eligibleCheck nodeSelector, tolerations, and node conditions
Pod won't startCheck logs for errors, resource limits
Pod evictedIncrease resource limits
Node not readyCheck node status, kubelet logs

DaemonSet vs Deployment Quick Reference

AspectDaemonSetDeployment
PurposeRun one Pod per nodeRun multiple Pods across cluster
ScalingAuto-scales with nodesManual scaling
Pods per nodeExactly oneMultiple
Use caseNode servicesApplication workloads
UpdateRollingUpdateRollingUpdate

Summary

AspectDaemonSet
PurposeNode-level system services
Pods per nodeExactly one
ScalingAuto-scales with nodes
Use casesMonitoring, logging, networking, storage, security
Update strategyRollingUpdate or OnDelete
Node selectionnodeSelector, tolerations, node affinity

DaemonSets are essential for running system-level services that need to be present on every node. They are the preferred way to deploy monitoring agents, log collectors, network plugins, and storage drivers in Kubernetes.


Learn More

Practice DaemonSets with hands-on exercises in our interactive labs:
https://devops.trainwithsky.com

Comments

Popular posts from this blog

🌐 Holographic Communications & 6G: The Future of Immersive Connectivity

  🌐 Holographic Communications & 6G: The Future of Immersive Connectivity 🚀 Introduction As the world moves towards 6G , a revolutionary technology is set to redefine digital interactions: Holographic Communications . Imagine real-time, 3D holographic video calls, immersive remote collaboration, and lifelike virtual experiences —all powered by ultra-fast, ultra-low-latency 6G networks . This topic explores Holographic Communications , its impact on various industries, key enabling technologies, and how 6G will bring this futuristic concept to reality . Shape Your Future with AI & Infinite Knowledge...!! Want to Generate Text-to-Voice, Images & Videos? http://www.ai.skyinfinitetech.com Read In-Depth Tech & Self-Improvement Blogs http://www.skyinfinitetech.com Watch Life-Changing Videos on YouTube https://www.youtube.com/@SkyInfinite-Learning Transform Your Skills, Business & Productivity – Join Us Today! 🔍 1. What is Holographic Communication? Hologr...

How to Use SKY TTS: The Complete, Step-by-Step Guide for 2025

 What is SKY TTS? SKY TTS  is a free, next-generation  AI audio creation platform  that brings together high-quality  Text-to-Speech ,  Speech-to-Text , and a full suite of professional  audio editing tools  in one seamless experience. Our vision is simple — to make advanced audio technology  free, accessible, and effortless  for everyone. From creators and educators to podcasters, developers, and businesses, SKY TTS helps users produce  studio-grade voice content  without expensive software or technical skills. With support for  70+ languages, natural voices, audio enhancement, waveform generation, and batch automation , SKY TTS has become a trusted all-in-one toolkit for modern digital audio workflows. Why Choose SKY TTS? Instant Conversion:  Enjoy rapid text-to-speech generation, even with large documents. Advanced Voice Settings:   Adjust speed, pitch, and style for a personalized listening experience. Multi-...

📊 Monitoring & Logging in Kubernetes – Tools like Prometheus, Grafana, and Fluentd

  Monitoring & Logging in Kubernetes – Tools like Prometheus, Grafana, and Fluentd Monitoring and logging are essential for maintaining a healthy and well-performing Kubernetes cluster. In this guide, we’ll cover why monitoring is important, key monitoring tools like Prometheus and Grafana, and logging tools like Fluentd to help you gain visibility into your cluster’s performance and logs. Shape Your Future with AI & Infinite Knowledge...!! Want to Generate Text-to-Voice, Images & Videos? http://www.ai.skyinfinitetech.com Read In-Depth Tech & Self-Improvement Blogs http://www.skyinfinitetech.com Watch Life-Changing Videos on YouTube https://www.youtube.com/@SkyInfinite-Learning Transform Your Skills, Business & Productivity – Join Us Today! 🚀 Introduction In today’s fast-paced cloud-native environment, Kubernetes has emerged as the de-facto container orchestration platform. But deploying and managing applications in Kubernetes is just half the ba...