Pages

Wednesday, 7 January 2026

Kubernetes DaemonSet

 


Kubernetes DaemonSet is a workload resource that ensures a specific pod runs on all (or selected) nodes in a cluster. It's commonly used for deploying node-level services like log collectors, monitoring agents, or network plugins.

Example:

Elasticsearch Agents are Elastic’s unified data shippers typically used in k8s cluster to collect container logs, Kubernetes metrics, node-level metrics and ship all of that data to Elasticsearch. They are deployed in the cluster as a DaemonSet.

We can use a DaemonSet to run a copy of a pod on every node, or we can use node affinity or selector rules to run it on only certain nodes.


What is the difference between ReplicaSet and DaemonSet?

ReplicaSets ensure a specific number of identical pods run for scaling stateless apps (e.g., web servers), while DaemonSets guarantee one pod runs on every (or a subset of) node(s) for node-specific tasks like logging or monitoring. The key difference is quantity versus location: ReplicaSets focus on maintaining pod count for availability, whereas DaemonSets ensure pod presence on each node for system-level services. 


ReplicaSet

  • Purpose: Maintain a stable set of replica pods for stateless applications, ensuring high availability and scalability.
  • Scaling: Scales pods up or down based on the replicas field you define in the manifest.
  • Use Case: Running web frontends, APIs, or any application needing multiple identical instances.
  • Behavior: If a pod dies, it creates a new one to meet the replica count; if a node fails, it tries to reschedule elsewhere. 


DaemonSet

  • Purpose: Run a single copy of a pod on every (or specific) node in the cluster for node-specific tasks.
  • Scaling: Automatically adds a pod when a new node joins the cluster and removes it when a node leaves.
  • Use Case: Logging agents (Fluentd, Elastic Agent), monitoring agents (Prometheus node-exporter), or storage daemons.
  • Behavior: Ensures that a particular service runs locally on each machine for local data collection or management. 


References:

DaemonSet | Kubernetes

DevOps Interview: Replica sets vs Daemon sets - DEV Community

No comments:

Post a Comment