DaemonSet in Kubernetes: A Comprehensive Guide
A DaemonSet is a crucial Kubernetes controller designed to manage pods across cluster nodes. Unlike other controllers like Deployments or ReplicaSets, a DaemonSet ensures that a pod runs on every node in a Kubernetes cluster. Whenever a new node is added, the DaemonSet automatically deploys the corresponding pod on it. Similarly, when a node is removed, the associated pods are cleaned up. This functionality makes DaemonSets indispensable for certain workloads in Kubernetes.

What is a DaemonSet?
In Kubernetes, DaemonSets are used when you need to ensure that a specific pod runs on every (or a subset of) node in a cluster. The most common use cases for DaemonSets include running system-wide services such as logging, monitoring, or storage management. For example, services like log collection or node monitoring often use DaemonSets to run on every node, ensuring data is gathered from the entire cluster.
Common Use Cases for DaemonSets
DaemonSets are versatile and can be used in a variety of scenarios. Here are some common examples:
- Cluster Storage: Running storage daemons like Glusterd or Ceph on each node for distributed storage systems.
- Logging: Deploying logging agents like Fluentd or Logstash to collect log data from each node.
- Monitoring: Running monitoring tools such as Prometheus Node Exporter, Collectd, or Datadog to track node performance.
Moreover, as the complexity of your use case increases, multiple DaemonSets can be deployed for various types of daemons, with configurable memory and CPU requests tailored to different hardware setups.
Creating a DaemonSet Deployment
To create your first DaemonSet, you need to define it in a YAML configuration file. Here’s a simple example for deploying a Prometheus exporter:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: prometheus-daemonset
spec:
selector:
matchLabels:
tier: monitoring
name: prometheus-exporter
template:
metadata:
labels:
tier: monitoring
name: prometheus-exporter
spec:
containers:
- name: prometheus
image: prom/node-exporter
ports:
- containerPort: 80
Once the YAML file is created, apply it using the kubectl command:
kubectl apply -f daemonset.yml
To verify that the DaemonSet has been successfully deployed, use the following command:
kubectl get daemonsets/prometheus-daemonset
You’ll see output indicating how many pods are running and their status.
Managing DaemonSets
To manage your DaemonSets, you can view detailed information about them using kubectl describe:
kubectl describe daemonset/prometheus-daemonset
If you ever need to remove a DaemonSet, use:
kubectl delete -f daemonset.yml
Restricting DaemonSets to Specific Nodes
By default, DaemonSets are deployed across all nodes in the cluster. However, there are situations where you might want to restrict pods to certain nodes. For instance, nodes running database pods may require different monitoring or logging settings.
You can achieve this by using a nodeSelector in the DaemonSet configuration. Here’s an example that deploys the DaemonSet only on a node named node1:
nodeSelector:
kubernetes.io/hostname: node1
This ensures that the DaemonSet pods are scheduled exclusively on node1, which might be required for specific workloads or configurations.
Accessing DaemonSet Pods
There are several methods for accessing DaemonSet pods within the cluster. The most common patterns include:
- Push Pattern: DaemonSet pods push data to central services like ElasticSearch rather than receiving traffic directly.
- NodeIP and Known Port Pattern: Pods use the
hostPortto expose services on the node’s IP address. Clients can access the pods using the node IP and a predefined port (e.g., port 80). - DNS Pattern: Create a Headless Service that selects the DaemonSet pods, enabling service discovery through DNS.
- Service Pattern: You can create a traditional Kubernetes Service that selects DaemonSet pods and exposes them using a
NodePort. However, note that this method lacks fine-grained control over which pod to access.
Why Choose ZippyOPS for Your Kubernetes Needs?
Managing Kubernetes clusters and implementing DaemonSets effectively requires expertise in various technologies like DevOps, Cloud, and AIOps. At ZippyOPS, we provide consulting, implementation, and managed services that ensure your Kubernetes environment is optimized for performance, security, and scalability. Our solutions cover a broad spectrum, from DataOps and MLOps to Microservices, Infrastructure, and Security.
For businesses looking to leverage Kubernetes for large-scale deployments, ZippyOPS offers specialized support in setting up, managing, and securing cloud-native architectures. Whether you’re implementing DevSecOps or need help automating operations, we’re here to guide you.
For more information on our services, visit ZippyOPS Services, ZippyOPS Solutions, or explore our products.
You can also watch our expert-led tutorials on our ZippyOPS YouTube Channel.



