DaemonSets
One Pod per node for log shippers, metrics agents, CNI and storage drivers: how DaemonSets pick nodes, their free tolerations, updates, and reaching them.
Deployments and ReplicaSetsLabels, selectors, annotations and namespaces
DaemonSets
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A DaemonSet runs one copy of a Pod on every eligible node, adds one when a node joins and removes it when the node leaves. There is no replicas field.
- Eligible means matching the template's nodeSelector and affinity, and tolerating the node's taints. The default scheduler places the Pods, pinned by a per-node affinity the controller adds.
- DaemonSet Pods get tolerations for not-ready, unreachable, pressure and unschedulable taints automatically, so they keep running on sick or cordoned nodes. Custom taints still need explicit tolerations.
- Updates roll one node at a time by default (maxUnavailable: 1); maxSurge lets the new Pod start before the old one stops, and OnDelete leaves timing to you.
- Typical DaemonSets are node agents: kube-proxy, CNI plugins, CSI node drivers, log shippers and node exporters. Keep their requests small, since every node pays them.
Work that belongs to the machine
Some software isn’t about your application at all. It is about the node. Every node needs something to ship its container logs, something to export its CPU and disk metrics, a network plugin to wire up Pod networking, a CSI driver to mount volumes, and kube-proxy to program Service rules. Exactly one copy per node, on every node, including the ones the autoscaler adds at 3 a.m.
A Deployment can’t express that. Ask for 10 replicas and you might get three on one node and none on another, and the count is wrong as soon as the cluster grows. A DaemonSet expresses it directly: “one of these on each node that qualifies”. The name comes from Unix daemons, the background services every machine runs.
How a DaemonSet chooses nodes
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: node-agent
namespace: kube-system
spec:
selector:
matchLabels: {app: node-agent}
updateStrategy:
type: RollingUpdate
rollingUpdate: {maxUnavailable: 1}
template:
metadata:
labels: {app: node-agent}
spec:
nodeSelector: {kubernetes.io/os: linux}
containers:
- name: agent
image: prom/node-exporter:v1.10.2
resources: {requests: {cpu: 50m, memory: 64Mi}, limits: {memory: 128Mi}}
There is no replicas. The controller works out the eligible nodes: those matching the template’s nodeSelector and node affinity, whose taints the Pod tolerates. For each, it creates a Pod with an extra node affinity that pins it to that one node. In the lab:
{"nodeAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":{"nodeSelectorTerms":
[{"matchFields":[{"key":"metadata.name","operator":"In","values":["worker-1"]}]}]}}}
The default scheduler then binds it, which means DaemonSet Pods respect resource limits and priorities like everything else. If a node is full, the agent can be left Pending, so node agents usually get a high priorityClassName such as system-node-critical.
The lab had four nodes: worker-1 and worker-2 labelled kubernetes.io/os=linux, a gpu-1 with the same label but a nvidia.com/gpu=present:NoSchedule taint, and an older fake-1 without the OS label. The DaemonSet reported DESIRED 2 and placed Pods only on the two workers. fake-1 failed the nodeSelector; gpu-1 failed on its taint.
The tolerations you get for free
The controller adds tolerations to every DaemonSet Pod. On the lab Pods:
node.kubernetes.io/not-ready:NoExecute
node.kubernetes.io/unreachable:NoExecute
node.kubernetes.io/disk-pressure:NoSchedule
node.kubernetes.io/memory-pressure:NoSchedule
node.kubernetes.io/pid-pressure:NoSchedule
node.kubernetes.io/unschedulable:NoSchedule
These keep node agents alive in exactly the situations they are most needed: a NotReady node (the nodes lesson showed those taints appearing), a node under disk or memory pressure, or a cordoned node being drained. They don’t cover your own taints. Adding tolerations: [{operator: Exists}] to the template, which tolerates everything, put a Pod on gpu-1 within seconds. Then a fifth node, worker-3, was created, and the DaemonSet grew to DESIRED 4 and placed a Pod there with no other change. Taints and tolerations covers the mechanism.
Because DaemonSet Pods tolerate unschedulable, kubectl drain needs --ignore-daemonsets: it leaves them running instead of evicting them, since the controller would only put them straight back.
Updating every node
updateStrategy.type: RollingUpdate, the default, replaces Pods node by node. maxUnavailable (default 1) limits how many nodes are without a ready agent at once. After changing the image to v1.10.3 in the lab, with a script marking new Pods Ready and completing old Pods’ termination in place of the kubelet:
t=2s worker-1:v1.10.2 worker-3:v1.10.2 gpu-1:v1.10.2 worker-2:v1.10.2 updated=
t=4s gpu-1:v1.10.3 worker-1:v1.10.2 worker-3:v1.10.2 worker-2:v1.10.2 updated=1
t=6s gpu-1:v1.10.3 worker-1:v1.10.2 worker-3:v1.10.2 worker-2:v1.10.3 updated=2
t=8s gpu-1:v1.10.3 worker-3:v1.10.2 worker-1:v1.10.3 worker-2:v1.10.3 updated=3
t=10s gpu-1:v1.10.3 worker-3:v1.10.3 worker-1:v1.10.3 worker-2:v1.10.3 updated=4
One node at a time. Normally the old Pod stops before the new one starts, leaving a short gap on each node. For agents where that gap hurts, such as a CNI plugin, maxSurge: 1 with maxUnavailable: 0 starts the new Pod alongside the old one, if the Pods can share the node (no conflicting hostPort). type: OnDelete updates a node’s Pod only when you delete it, for careful hand-rolled upgrades.
Talking to a node agent
Apps often need the agent on their node: send logs or traces to the local collector, not one across the cluster. Options, roughly in order of use:
- hostPort or hostNetwork on the agent, with the app reaching it at its node’s IP, which the downward API exposes as
status.hostIP. - A Service with
internalTrafficPolicy: Local, so traffic goes only to the agent on the same node. - A headless Service when you want DNS records for every agent.
- Unix sockets on a shared
hostPath, as CSI drivers and some log agents do.
Keep them small
Every DaemonSet is a fixed tax on every node. Its requests are reserved before any workload, and its memory limit is a real risk: an agent OOM-killed on every node at once is a cluster-wide outage. Give agents honest requests, a memory limit with headroom, and a high priority, and review how many you run. Mature clusters often have half a dozen: kube-proxy, a CNI, a CSI node driver, a log shipper, a metrics exporter and a security agent.
About the video
The embed is Marcel Dempers’ “Kubernetes Daemonsets explained” on That DevOps Guy (May 2021, 27 minutes). Its chapters cover a basic DaemonSet deployment, scheduling and tolerations, how other Pods communicate with daemon Pods (Services, host ports, headless Services and DNS) and real-world use cases. The communication part is the most useful and the least covered elsewhere. It predates DaemonSet maxSurge going GA and internalTrafficPolicy, which the lesson adds. English was judged from the English title and caption track; there is no audio-track metadata. Pavan Elthepu’s video in deeper deploys the Prometheus node exporter and looks at kube-proxy’s own DaemonSet.
What was run: the node selection, the per-node affinity, the automatic tolerations, the GPU-taint exclusion and toleration, the new-node Pod and the one-node-at-a-time rolling update ran against a local v1.37.3 control plane on 2026-11-28. Its nodes run no containers, so Pod readiness and the end of old Pods’ termination were simulated by a script standing in for the kubelet. Host networking and Service traffic need real nodes and are described from the docs.
Where this fits
The last kind of workload runs to completion instead of forever: Jobs and CronJobs.
Check yourself
You add a node to the cluster. What do you need to do for your log shipper to run on it?
Nothing, provided the node matches the DaemonSet's nodeSelector and affinity and has no taint the Pods don't tolerate. The DaemonSet controller sees the new Node and creates a Pod for it.
Your GPU nodes carry a nvidia.com/gpu NoSchedule taint and the monitoring agent is missing from them. Why, and what fixes it?
DaemonSet Pods only get automatic tolerations for built-in node-condition taints. A custom taint repels them like any Pod. Add a matching toleration to the template, or operator: Exists to tolerate everything, which is common for node agents.
A node is cordoned for maintenance. Do its DaemonSet Pods keep running, and does kubectl drain remove them?
They keep running, because DaemonSet Pods tolerate the unschedulable taint. kubectl drain refuses to proceed unless you pass --ignore-daemonsets, and even then it leaves them in place; deleting them would only make the controller recreate them.
Why does every DaemonSet Pod's request matter more than a Deployment Pod's?
It is multiplied by the number of nodes and reserved on each one before any workload is placed. 200m of CPU across 300 nodes is 60 cores of capacity spent on one agent.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.