
Use Cases for DaemonSets
DaemonSets are particularly useful in scenarios where you need to run background services or agents on every node. Some common use cases include:- Monitoring agents and log collectors: Deploy monitoring tools or log collectors across every node to ensure comprehensive cluster-wide visibility without manual intervention.
- Essential Kubernetes components: Deploy critical components, such as kube-proxy, which Kubernetes requires on all worker nodes.
- Networking solutions: Ensure consistent deployment of networking agents like those used in VNet or weave-net across all nodes.



Creating a DaemonSet
Creating a DaemonSet is analogous to creating a ReplicaSet. The DaemonSet YAML configuration consists of a pod template under thetemplate section and a selector that binds the DaemonSet to its pods. A typical DaemonSet definition includes the API version, kind, metadata, and specifications. Note that the API version is apps/v1 and the kind is set to DaemonSet.
Below is an example DaemonSet definition file that deploys a monitoring agent:
How DaemonSets Schedule Pods
Prior to Kubernetes version 1.12, scheduling a pod on a specific node was often achieved by manually setting thenodeName property within the pod specification. However, since version 1.12, DaemonSets leverage the default scheduler in conjunction with node affinity rules. This improvement ensures that a pod is automatically scheduled on every node without manual intervention.
