What is a DaemonSet and when do you use one?
Quick Answer
A DaemonSet runs exactly one copy of a pod on every node (or a selected subset), and automatically adds/removes pods as nodes join or leave. Use it for node-level agents: log collectors, monitoring, CNI, and storage daemons.
Detailed Answer
Unlike a Deployment (N replicas placed anywhere), a DaemonSet guarantees one pod per matching node. When a node is added, the DaemonSet controller schedules its pod there; when a node is removed, that pod is cleaned up. This is exactly what node-local infrastructure needs: a log shipper (Fluent Bit) reading each node's logs, a metrics agent (node-exporter), the CNI plugin, kube-proxy itself, or a CSI storage node driver. DaemonSet pods typically tolerate taints (so they also land on control-plane/specialized nodes) and use nodeSelector/affinity to target a subset (e.g., only GPU nodes). They roll out with their own update strategy (RollingUpdate) node by node.
Code Example
apiVersion: apps/v1
kind: DaemonSet
metadata: { name: node-exporter }
spec:
selector: { matchLabels: { app: node-exporter } }
template:
metadata: { labels: { app: node-exporter } }
spec:
tolerations: [{ operator: "Exists" }] # run on every node incl. tainted
containers: [{ name: node-exporter, image: prom/node-exporter }]Interview Tip
Anchor it in examples the interviewer knows: 'kube-proxy, CNI, node-exporter, and log shippers are DaemonSets.' Mention tolerations so it also lands on tainted nodes.