What is a DaemonSet and when would you use one?
Understand what a Kubernetes DaemonSet is, how it runs one pod per node, how it differs from a Deployment, and its logging and monitoring use cases.
Expected Interview Answer
A DaemonSet ensures that a copy of a specific pod runs on every node (or every node matching a selector) in the cluster, automatically adding the pod to new nodes and removing it from deleted ones. It is used for node-level agents like log collectors, monitoring exporters, and networking or storage daemons.
Unlike a Deployment, which schedules a target replica count across arbitrary nodes, a DaemonSet is node-scoped: exactly one pod per eligible node. As nodes join the cluster, the DaemonSet controller schedules the pod onto them; as nodes leave, their pods are garbage-collected. Node selectors, affinity, and tolerations control which nodes are eligible, letting DaemonSet pods run even on tainted control-plane nodes when required.
- Guarantees one pod per node automatically
- Covers new nodes without manual steps
- Ideal for logging, monitoring and networking agents
- Respects taints via tolerations to reach all nodes
- Simplifies cluster-wide infrastructure rollout
AI Mentor Explanation
A DaemonSet is like posting one dedicated umpire at every single ground where matches are played. Open a new ground and an umpire is automatically assigned; close one and the umpire leaves. You never count total umpires against fixtures — the rule is simply one per venue, so every pitch always has its own official present.
Step-by-Step Explanation
Step 1
Define the pod template
Describe the agent container that must run on each node, such as a log shipper or metrics exporter.
Step 2
Add tolerations if needed
Include tolerations so the pod can run on tainted nodes like control-plane nodes when required.
Step 3
Scope eligible nodes
Use nodeSelector or affinity to restrict the DaemonSet to a subset of nodes, e.g. GPU nodes.
Step 4
Apply and let the controller reconcile
The DaemonSet controller places one pod on every matching node automatically.
Step 5
Handle updates
Use the RollingUpdate strategy to replace DaemonSet pods node-by-node without cluster-wide downtime.
What Interviewer Expects
- One-pod-per-node semantics
- Correct use cases: logging, monitoring, networking
- Difference from Deployment replica scheduling
- Awareness of tolerations for tainted nodes
- Node selector/affinity to target a subset
Common Mistakes
- Using a Deployment where a DaemonSet is needed
- Forgetting tolerations, so control-plane nodes are skipped
- Thinking you set a replica count on a DaemonSet
- Assuming it auto-scales pods per node beyond one
Best Answer (HR Friendly)
“A DaemonSet makes sure one copy of a helper program runs on every machine in the cluster. It is perfect for things like log collectors or monitoring agents, and it automatically starts on new machines and stops when machines are removed, so you never have to manage each one by hand.”
Code Example
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd
namespace: logging
spec:
selector:
matchLabels:
app: fluentd
template:
metadata:
labels:
app: fluentd
spec:
tolerations:
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
containers:
- name: fluentd
image: fluent/fluentd:v1.17
resources:
requests:
cpu: "100m"
memory: "128Mi"
volumeMounts:
- name: varlog
mountPath: /var/log
volumes:
- name: varlog
hostPath:
path: /var/logFollow-up Questions
- How does a DaemonSet differ from a Deployment?
- How do you run a DaemonSet pod on only a subset of nodes?
- Why are tolerations often needed on DaemonSets?
- How does a rolling update work for a DaemonSet?
- Give three real-world DaemonSet use cases.
MCQ Practice
1. What does a DaemonSet guarantee?
A DaemonSet runs exactly one copy of its pod on every node that matches its selector.
2. Which is a classic DaemonSet use case?
Node-level agents like log collectors and monitoring exporters are the canonical DaemonSet workloads.
3. How does a DaemonSet reach tainted control-plane nodes?
Tolerations let DaemonSet pods schedule onto nodes whose taints would otherwise repel them.
Flash Cards
What does a DaemonSet do? — Runs one copy of a pod on every eligible node, automatically covering new nodes.
DaemonSet vs Deployment? — DaemonSet is one-pod-per-node; Deployment schedules a replica count across arbitrary nodes.
Why add tolerations to a DaemonSet? — So its pods can run on tainted nodes such as control-plane nodes.
Name two DaemonSet use cases. — Log collectors (Fluentd) and monitoring exporters (node-exporter); also CNI/CSI agents.