DaemonSets
A DaemonSet ensures that a copy of a Pod runs on all (or a subset of) nodes in the cluster.
- When a new node is added to the cluster, the DaemonSet automatically schedules a Pod on it
- When a node is removed, the Pod is garbage collected
- Deleting a DaemonSet removes all the Pods it created
More Information
Exampleโ
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd
spec:
selector:
matchLabels:
name: fluentd
template:
metadata:
labels:
name: fluentd
spec:
containers:
- name: fluentd
image: fluentd:latest
Use Casesโ
- Log collection agents (Fluentd, Filebeat)
- Monitoring agents (Prometheus Node Exporter, Datadog)
- Network plugins (Calico, Cilium)
- Storage daemons (Ceph, GlusterFS)
Running on Specific Nodesโ
- Use
nodeSelectorornodeAffinityto schedule the DaemonSet only on specific nodes - Use tolerations to run on tainted nodes (e.g. control-plane nodes)
spec:
template:
spec:
nodeSelector:
role: monitoring
tolerations:
- key: node-role.kubernetes.io/control-plane
effect: NoSchedule