When managing containerized workloads in Kubernetes, understanding the difference between a DaemonSet and a Deployment is crucial for proper infrastructure setup.
A standard Deployment specifies a desired number of replicas and lets the scheduler distribute those pods across available nodes. This can lead to an uneven spread—for example, three pods on one node while another node remains empty.
A DaemonSet, on the other hand, guarantees that exactly one pod runs on every eligible node. When a new node is added, a pod is automatically scheduled there; when a node is removed, its corresponding pod is cleaned up. This makes DaemonSets ideal for node-level agents such as:
- Logging collectors (e.g., Fluent Bit)
- Monitoring agents (e.g., Node Exporter)
- Network plugins/CNI (e.g., Calico, Cilium)
You can also restrict DaemonSets to run only on specific nodes using nodeSelector (e.g., only GPU nodes) or tolerations to allow them on control-plane nodes.
⚠️ Important: "One per node" means one per eligible node. DaemonSets are designed for lightweight node agents; for stateless application scaling, Deployments remain the correct choice.