A DaemonSet is used when you want the same pod to run on all (or selected) machines automatically.
Kubernetes takes care of it for you.
You write the YAML once, and Kubernetes puts that pod on every machine.
Think of it like this:
“You tell your office manager to put the same poster on all desks. Now, you don’t need to do it yourself—it happens automatically!”
When to use which?
- Use Static Pod: When setting up core system components or starting Kubernetes itself.
- Use DaemonSet: When you want something to run on all nodes automatically (like logs collector or antivirus).
Example of DaemonSet (Monitoring Agent)
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: log-agent
spec:
selector:
matchLabels:
app: log-agent
template:
metadata:
labels:
app: log-agent
spec:
containers:
– name: log-agent
image: mycompany/log-agent:latest
Side car also we can use but its not work on node level , it work on pod level.
If you use a DaemonSet, Kubernetes will automatically create one pod on each node in your cluster — no manual step needed for each node.
🔁 What happens automatically:
- You deploy a DaemonSet once.
- Kubernetes watches all nodes.
- As soon as a node exists, one pod is created there.
- If a new node is added later, it also gets the pod.
📦 Use cases:
- Running log collectors (e.g., Fluentd)
- Running monitoring agents (e.g., Prometheus Node Exporter)
- Custom scripts or services you want on every node