DaemonSet updates and use cases
Choose the controller by the unit of work
Use a Deployment for an interchangeable pool of HTTP workers, a StatefulSet for workloads needing stable member identity, and a DaemonSet for a node-local function such as collecting node metrics. An ordinary heartbeat demo needs neither privileged execution nor real host logs. This distinction is especially important when reading examples of networking or monitoring add-ons: their elevated permissions are product-specific, not a DaemonSet requirement.
Design a harmless heartbeat agent
env:- name: NODE_NAME valueFrom: fieldRef: fieldPath: spec.nodeNameUse local identity without API access
The downward API can place the assigned node name into an environment variable. A hypothetical heartbeat process could emit its node name and a synthetic health marker to stdout; it does not need to list nodes or read the host filesystem. The full fixture disables automatic service account token mounting, drops capabilities, requires a non-root user and sets small resource bounds. The image is deliberately non-resolvable: a reviewed image and actual application tests are required before execution. No heartbeat output is claimed.
Control how an agent is replaced
minReadySeconds: 10updateStrategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 maxSurge: 0Follow a four-node update
With four eligible nodes, a budget of one unavailable and no surge, the controller can replace an old agent and wait for its replacement to become available before spending the budget on another node. In rollout.json, the new agent becomes Ready while its availability is still delayed by the ten-second minimum. The snapshot then returns to four available before the next replacement. The final snapshot has four updated and four available. These are illustrative observations with fixed membership and no unrelated failures, not timing guarantees. In particular, failures can reduce actual availability below the rollout target.
Understand surge and manual replacement
RollingUpdate automatically reacts to a Pod-template change. OnDelete leaves existing agents in place until their Pods are removed. A positive maxSurge can temporarily allow a new agent alongside an old available agent on the same node; plan for additional local resources and any exclusive-port conflicts. Both surge and unavailable budgets cannot be zero together. In the DaemonSet API, percentage budgets round up: 25% of seven intended nodes gives two, not one. This differs from the Deployment maxUnavailable rounding rule. Do not use a global delete command to drive updates.
Verify coverage and the function itself
kubectl --context daemon-lab -n daemon-study get daemonset heartbeatkubectl --context daemon-lab -n daemon-study get pods -l app=heartbeat -o widekubectl --context daemon-lab -n daemon-study rollout status daemonset/heartbeat --timeout=60sPractice a rollout decision
The commands require an explicitly approved disposable context and existing lab resources; they were not run. Compare desired, updated, ready and available counts, ensure the controller has observed the intended generation, then check agent output per eligible node. A completed rollout is not proof of correct telemetry. For an independent exercise, choose a strategy for six nodes where replacing two agents at once is unacceptable. Explain how you would verify the new agent and how to halt further planned changes for investigation if failures occur. A one-unavailable, zero-surge budget is a starting point, not a service-level guarantee.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
DaemonSet updates and use cases — knowledge check
Apply the chapter concepts using synthetic offline scenarios.
Which workload most naturally fits a DaemonSet?
How can the agent learn its assigned node name without calling the API?
With minReadySeconds=10, a replacement becomes Ready just now. What follows?
A DaemonSet has nine desired nodes and maxUnavailable=20%. What is the rounded budget?
What happens with OnDelete after a Pod-template change?