Kubernetes DaemonSet Update Strategies
Configure DaemonSet rolling updates with maxUnavailable and maxSurge. Understand OnDelete vs RollingUpdate strategies for node-level workloads.
π‘ Quick Answer: DaemonSets support
RollingUpdate(automatic, one node at a time) andOnDelete(manual, update only when pod is deleted). UsemaxUnavailableandmaxSurgeto control rollout speed.
The Problem
DaemonSets run on every node (monitoring agents, log collectors, network plugins). Updating them requires care:
- Taking down all monitoring at once blinds you during the rollout
- Network plugins (CNI) canβt tolerate downtime β traffic drops
- Node-level agents may need the old version removed before the new starts
- Large clusters need parallel updates for speed
The Solution
RollingUpdate (Default)
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: node-exporter
spec:
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
selector:
matchLabels:
app: node-exporter
template:
metadata:
labels:
app: node-exporter
spec:
containers:
- name: exporter
image: prom/node-exporter:v1.8.0
ports:
- containerPort: 9100
hostPort: 9100Fast Parallel Update
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: "25%"
# Update 25% of nodes simultaneouslyMaxSurge (Zero Downtime)
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
# New pod starts BEFORE old is removedOnDelete (Manual Control)
updateStrategy:
type: OnDelete
# Pods only update when manually deleted# Manually trigger update on specific nodes
kubectl delete pod node-exporter-abc12 -n monitoring
# New pod starts with updated imageMonitor Rollout
kubectl rollout status daemonset/node-exporter -n monitoring
kubectl rollout history daemonset/node-exporter -n monitoring
kubectl rollout undo daemonset/node-exporter -n monitoringgraph TD
subgraph RollingUpdate maxUnavailable=1
N1[Node 1: Update β] --> N2[Node 2: Updating...]
N2 --> N3[Node 3: Waiting]
N3 --> N4[Node 4: Waiting]
end
subgraph OnDelete
N5[Node 1: Old version]
N6[Node 2: Old version]
N7[Node 3: Deleted β New version]
endCommon Issues
DaemonSet rollout stuck A pod on one node canβt start (resource constraints, node issues):
kubectl get pods -l app=node-exporter -o wide | grep -v Running
kubectl describe pod <stuck-pod>maxSurge not working with hostPort Two pods canβt use the same hostPort on one node. maxSurge requires the old pod to release the port first. Use maxUnavailable: 1 instead for hostPort DaemonSets.
Rollback not working DaemonSets track revisions like Deployments:
kubectl rollout history daemonset/node-exporter
kubectl rollout undo daemonset/node-exporter --to-revision=2Best Practices
- Use
maxUnavailable: 1for critical infrastructure (CNI, logging) - Use
maxUnavailable: 25%for large clusters (100+ nodes) to speed rollouts - Use
maxSurge: 1withmaxUnavailable: 0for zero-gap monitoring agents - Use
OnDeletefor CNI plugins where automatic restart is risky - Combine with node cordoning for controlled cluster-wide upgrades
- Set resource requests to ensure new pod can be scheduled alongside old
Key Takeaways
RollingUpdateis the default β updates nodes progressivelyOnDeletegives full manual control β useful for critical infrastructuremaxUnavailablecontrols how many nodes lose the DaemonSet pod simultaneouslymaxSurge(1.22+) allows new pod to start before old is removed (zero-gap)maxSurgeandmaxUnavailablecanβt both be zero- hostPort DaemonSets canβt use
maxSurge(port conflict)

Recommended
Kubernetes Recipes β The Complete Book100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Get the Book βLearn by Doing
CopyPasteLearn β Hands-on Cloud & DevOps CoursesMaster Kubernetes, Ansible, Terraform, and MLOps with interactive, copy-paste-run lessons. Start free.
Browse Courses βπ Deepen Your Skills β Hands-on Courses
Courses by CopyPasteLearn.com β Learn IT by Doing
