DaemonSet
A Kubernetes resource that ensures a pod runs on every (or selected) node in a cluster, automatically spawning new instances when nodes are added.
A DaemonSet is a Kubernetes controller that deploys and maintains a copy of a specified pod on each node in a cluster. Unlike Deployments, which run a fixed number of replicas, DaemonSets guarantee one pod per node, making them ideal for infrastructure-level services that need to run on all machines.
Common use cases include log collectors (Filebeat, Fluentd), monitoring agents (Prometheus node exporter), security tools (Falco), and network plugins (CNI implementations). When a new node joins the cluster, the DaemonSet automatically schedules a pod there; when a node is removed, the pods are cleaned up.
You can use node selectors or taints/tolerations to restrict which nodes receive DaemonSet pods. For example:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: log-collector
spec:
selector:
matchLabels:
app: logs
template:
metadata:
labels:
app: logs
spec:
containers:
- name: collector
image: filebeat:latest