DaemonSet

On this page 7

A DaemonSet is a Kubernetes workload controller that ensures one copy of a given pod runs on every node in a cluster, or on every node that matches a selector. In Kubernetes, DaemonSets are the standard way to deploy node-level agents, such as log collectors, monitoring exporters, network plugins and storage drivers, which must be present wherever workloads run.

Unlike a Deployment, which keeps a requested number of replicas somewhere in the cluster, a DaemonSet ties its pod count to the number of eligible nodes. When a node joins, the controller adds a pod there automatically; when a node is removed, its pod is garbage-collected. The resource belongs to the apps/v1 API group.

How a DaemonSet places pods on nodes

The DaemonSet controller continuously compares the set of eligible nodes with the pods it owns. For each eligible node without a pod, it creates one with a node affinity rule that pins the pod to that node, and the default scheduler then binds it. Since Kubernetes 1.12, this path through the regular scheduler means DaemonSet pods respect priorities, preemption and resource checks like other pods.

Eligibility is controlled by three mechanisms. A nodeSelector or node affinity restricts the set to labeled nodes, such as only GPU nodes. Taints and tolerations decide whether pods may run on tainted nodes, including control-plane nodes. Finally, the controller automatically adds tolerations for conditions such as not-ready, unreachable, disk pressure and memory pressure, so node agents stay in place when a node is unhealthy, which is exactly when they are often needed.

The table below summarizes the fields that shape DaemonSet behavior.

FieldPurposeTypical value
selectorMatches the pods the DaemonSet ownsMust equal the pod template labels
template.spec.nodeSelectorLimits pods to labeled nodesFor example a GPU or storage node label
template.spec.tolerationsAllows pods on tainted nodesControl-plane taint for cluster-wide agents
updateStrategyControls how new versions roll outRollingUpdate (default) or OnDelete
priorityClassNameProtects agents from evictionsystem-node-critical for essential agents
minReadySecondsDelay before a new pod counts as available0 to 30 seconds
Key DaemonSet specification fields

Typical DaemonSet workloads

DaemonSets fit any software that must observe or extend the node itself rather than serve application traffic. Such pods often use hostPath volumes, hostNetwork or privileged mode to reach node resources, which makes them powerful and security-sensitive.

CategoryExample agentsNode resources used
Log collectionFluent Bit, Fluentd, Vector, FilebeatContainer log files on the host
MonitoringPrometheus node exporter, Datadog agentHost metrics, /proc and /sys
NetworkingCalico, Cilium, kube-proxyHost network stack, iptables or eBPF
StorageCSI node pluginsDevice mounts and the kubelet directory
SecurityRuntime threat detection, file integrity agentsKernel events, process activity
Common uses of DaemonSets

Rolling out updates safely

Because a DaemonSet touches every node at once, a faulty update can break logging, networking or storage across the whole cluster. The update strategy therefore deserves careful tuning.

StrategyBehaviorWhen to use it
RollingUpdate, maxUnavailable 1Replaces pods one node at a timeDefault, cautious rollout
RollingUpdate, maxUnavailable 10-25%Replaces pods on a share of nodes in parallelLarge clusters needing faster rollouts
RollingUpdate with maxSurgeStarts the new pod before stopping the old oneAgents that must not have a gap, if ports allow
OnDeleteUpdates a pod only after it is deleted manuallyCritical agents under strict change control
DaemonSet update strategies

Rollouts can be watched with kubectl rollout status and reversed with kubectl rollout undo. Readiness probes and minReadySeconds ensure that the controller only proceeds when the new pod on a node is actually healthy.

For critical agents such as a network plugin, many teams first test a new version on a small labeled node pool, often by running a second DaemonSet with a narrower nodeSelector, before updating the main DaemonSet. This canary approach limits the impact of a bad release to a few nodes and gives monitoring time to catch regressions.

DaemonSet compared with other workload controllers

Each Kubernetes workload controller answers a different question about where and how many pods run. Choosing the wrong one is a common design error.

ControllerPod count determined byPod identityTypical workload
DaemonSetNumber of eligible nodesOne per nodeNode agents
DeploymentReplica count or autoscalerInterchangeableStateless applications
StatefulSetReplica countStable name and storageDatabases, queues
JobCompletions and parallelismRun to completionBatch tasks
Static podManifest file on a nodeManaged by the kubeletControl-plane components
DaemonSet and neighboring controllers

A Deployment with pod anti-affinity can approximate one pod per node, but it does not react to new nodes automatically and cannot follow node labels as precisely, so a DaemonSet remains the correct tool for agents.

Pitfalls and good practices

  • Resource requests multiply by node count: a request of 200 millicores on 300 nodes reserves 60 cores, so size agents carefully.
  • Missing tolerations: without them, agents silently skip tainted nodes, leaving gaps in logging or monitoring.
  • Overprivileged pods: hostPath mounts, hostNetwork and privileged mode give broad node access; grant only what the agent needs.
  • Eviction under pressure: without an appropriate priority class, essential agents may be evicted before ordinary workloads.
  • Aggressive rollouts: a high maxUnavailable value for a network plugin can disrupt traffic on many nodes simultaneously.

Well-run clusters keep the number of DaemonSets small and deliberate, because every one consumes capacity on every node and widens the attack surface.

The short version

Picture a hotel chain that wants one security guard in every building. When a new hotel opens, a guard is assigned there automatically. When a hotel closes, its guard leaves. Nobody has to count guards by hand.

A DaemonSet does the same for a cluster of servers. It makes sure that every machine runs its own copy of a helper program, such as one that collects logs or watches performance. New machines get the helper automatically.

Where it makes a difference

A platform team runs a Kubernetes cluster that autoscales between 20 and 120 nodes during the day. To centralize logs, they deploy Fluent Bit as a DaemonSet that reads container log files from each node through a read-only hostPath volume and forwards them to a central log store. Each pod requests 100 millicores and 128 MiB of memory and tolerates the control-plane taint.

When the autoscaler adds 40 nodes during a traffic peak, each new node receives a Fluent Bit pod within seconds of becoming ready, so no log lines are lost from new application pods. A later configuration update rolls out with maxUnavailable set to 10 percent, and a faulty parser is caught on the first few nodes before reaching the rest of the cluster.