A DaemonSet ensures that exactly one copy of a specific Pod runs on each Node (or selected
Nodes) in a Kubernetes cluster. It’s ideal for deploying node-level services like monitoring
agents, logging daemons, or networking tools (e.g., kube-proxy, Calico, Cilium).
DaemonSet Pods are not scheduled by the default Scheduler but directly placed by the DaemonSet
controller. They automatically deploy Pods to new Nodes as they are added to the cluster, and
remove Pods when Nodes are deleted. Pod placement can be controlled with nodeSelectors,
affinity, taints, and tolerations.
Example YAML manifest:
apiVersion: apps/v1kind: DaemonSetmetadata: name: fluentd-agent namespace: default labels: k8s-app: fluentd-agentspec: selector: matchLabels: k8s-app: fluentd-agent template: metadata: labels: k8s-app: fluentd-agent spec: containers: - name: fluentd image: quay.io/fluentd_elasticsearch/fluentd:v4.5.2Key commands:
kubectl create -f fluentd-ds.yamlkubectl apply -f fluentd-ds.yaml --recordkubectl get daemonsetskubectl describe ds fluentd-agentkubectl rollout status ds fluentd-agentkubectl set image ds fluentd-agent fluentd=quay.io/fluentd_elasticsearch/fluentd:v4.6.2 --recordkubectl rollout undo ds fluentd-agent --to-revision=1kubectl delete ds fluentd-agentDaemonSets are essential for ensuring consistent background services are running across the entire cluster or a specific subset of Nodes.