Understanding Kubernetes DaemonSet: Setup, Scheduling & Updates
In Kubernetes, a Kubernetes DaemonSet is an essential resource that ensures all (or specific) nodes in a cluster run a copy of a particular pod. As nodes are added or removed from the cluster, the DaemonSet ensures that the appropriate pods are scheduled and cleaned up automatically. This functionality is critical for maintaining consistency and availability across your infrastructure, particularly for services like logging, monitoring, and storage.
In this post, we’ll explore how DaemonSets work in Kubernetes, their common use cases, and how to manage them efficiently. If you need assistance with your Kubernetes infrastructure or want to optimize your DevOps processes, ZippyOPS offers expert consulting, implementation, and managed services to guide your cloud transformation.

What is a Kubernetes DaemonSet?
A Kubernetes DaemonSet guarantees that a pod runs on all nodes in a cluster or on selected nodes. When a new node is added, the DaemonSet controller automatically deploys the specified pod onto it. Similarly, when nodes are removed, the associated pods are cleaned up.
Common use cases for DaemonSets include:
- Running a cluster storage daemon, like Glusterd or Ceph.
- Deploying log collection daemons such as Fluentd or Logstash.
- Implementing node monitoring daemons, including Prometheus Node Exporter, Datadog Agent, or Sysdig Agent.
A simple cluster may use a single DaemonSet for each daemon type, but more complex setups could involve multiple DaemonSets with varied configurations depending on the hardware.
Example of Creating a DaemonSet
To create a DaemonSet, you’ll typically define it in a YAML configuration file. Here’s an example configuration to deploy Fluentd with Elasticsearch integration:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd-elasticsearch
namespace: kube-system
labels:
k8s-app: fluentd-logging
spec:
selector:
matchLabels:
name: fluentd-elasticsearch
template:
metadata:
labels:
name: fluentd-elasticsearch
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- name: fluentd-elasticsearch
image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: varlog
mountPath: /var/log
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
terminationGracePeriodSeconds: 30
volumes:
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
After defining the YAML file, you can create the DaemonSet using the following command:
kubectl create -f daemonset.yaml
This will initiate the DaemonSet, and you can check its status with:
kubectl get pods --all-namespaces
How Daemon Pods Are Scheduled in Kubernetes
Unlike standard pods, which are scheduled by the Kubernetes scheduler, DaemonSet pods are managed by the DaemonSet controller. When the DaemonSet controller creates a pod, the target node is predetermined, so the pod is not scheduled by the standard Kubernetes scheduler.
Key Points:
- The DaemonSet controller ignores the
.spec.nodeNamefield, which is typically used by the scheduler to assign a node. - DaemonSet pods can be created even before the Kubernetes scheduler starts, which is useful for initial cluster bootstrapping.
ZippyOPS can assist you in optimizing your Kubernetes scheduling and infrastructure to improve operational efficiency. We specialize in DevOps, Cloud, and AIOps strategies that help streamline and automate your workloads.
Communication Patterns for DaemonSet Pods
Communicating with DaemonSet pods can be done using several methods:
- Push Pattern: DaemonSet pods can push data to other services, like a statistics database.
- Node IP and Known Port: By using the
hostPortattribute, DaemonSet pods can be accessed via node IPs and specific ports. - DNS-Based Communication: A headless service can be created, allowing discovery of DaemonSet pods using DNS and endpoints.
- Service: A Kubernetes service can be used to reach a DaemonSet pod, although there is no way to target a specific node directly.
Each communication method has its own advantages depending on your specific requirements for service discovery and traffic routing.
Updating a Kubernetes DaemonSet
Updating a DaemonSet can be straightforward, but it comes with some important considerations:
- Node Label Changes: If node labels are modified, the DaemonSet will add or remove pods accordingly.
- Pod Template Modifications: While you can modify some aspects of the pods created by a DaemonSet, not all fields can be updated directly.
- Deleting DaemonSets: When deleting a DaemonSet, you can specify
--cascade=falseto leave the pods on the nodes. If you create a new DaemonSet with the same selector, it can adopt the existing pods, and the DaemonSet controller will replace any outdated pods according to its update strategy. - For a deeper understanding of Kubernetes networking patterns, including best practices for service discovery and DNS management, consider checking out this guide from Kubernetes documentation.
Conclusion
A Kubernetes DaemonSet is a crucial component for maintaining consistency and reliability across nodes in your cluster. Whether you’re deploying logging services, monitoring agents, or storage solutions, DaemonSets ensure that your services are consistently available. For more complex setups or performance optimizations, ZippyOPS offers tailored solutions for Cloud, DevOps, and Infrastructure management.
If you’re looking to streamline your operations or need expert assistance with Kubernetes, DevSecOps, or MLOps, reach out to ZippyOPS for consulting and managed services. Contact us at sales@zippyops.com to learn more.



