CodeBlanks Logo Icon CodeBlanks

Updating a DaemonSet

Learn the DaemonSet rolling update strategy.

Updating

DaemonSets have two update strategies:

  • RollingUpdate (default): nodes are updated one by one; maxUnavailable sets how many nodes may be without the agent at once.
  • OnDelete: nothing happens when the template changes; when a pod is deleted by hand, the new one is created with the new template. It's used for controlled updates of critical components like network plugins.
spec:
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1

kubectl set image ds/node-exporter exporter=prom/node-exporter:v1.8.3 -n izleme
kubectl rollout status ds/node-exporter -n izleme

History and rollback

A DaemonSet also keeps a rollout history and is rolled back with the same commands as a Deployment:

$ kubectl rollout history ds/node-exporter -n izleme
REVISION  CHANGE-CAUSE
1         <none>
2         <none>
$ kubectl rollout undo ds/node-exporter -n izleme
daemonset.apps/node-exporter rolled back

Practice Update the agent

Write three commands: set the image of the exporter container in the node-exporter DaemonSet in the izleme namespace to prom/node-exporter:v1.8.3; wait for the rollout to finish; show the history.

Starter code

terminal
# buraya yaz

Sample solution

terminal
kubectl set image ds/node-exporter exporter=prom/node-exporter:v1.8.3 -n izleme
kubectl rollout status ds/node-exporter -n izleme
kubectl rollout history ds/node-exporter -n izleme

Expected output

daemonset.apps/node-exporter image updated
Waiting for daemon set "node-exporter" rollout to finish: 1 out of 3 new pods have been updated...
daemon set "node-exporter" successfully rolled out
REVISION  CHANGE-CAUSE
1         <none>
2         <none>

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Under the OnDelete strategy, what happens when the image is changed?

  • All update immediately
  • The DaemonSet is deleted
  • It errors
  • Running pods don't change; ones deleted by hand are created with the new image Correct answer

Explanation: The operator decides the timing and order of the update.

2 Set the update to be triggered by hand.

Question
spec:
  updateStrategy:
    type: ____
Answer
spec:
  updateStrategy:
    type: OnDelete

Explanation: OnDelete updates when a pod is deleted.

3 Match.

Term Meaning
RollingUpdate Update node by node
OnDelete Update when deleted by hand
maxUnavailable Limit on agentless nodes
rollout undo ds/ Roll back

All lessons in Advanced