Home Explore Blog CI



kubernetes

9th chunk of `content/en/blog/_posts/2017-09-00-Kubernetes-Statefulsets-Daemonsets.md`
eda19f392a0da39698c3781d6be3adec5b23a03801571f8e0000000100000883



```  
$ kubectl rollout history ds node-exporter   
daemonsets "node-exporter"  
REVISION               CHANGE-CAUSE  

1                             kubectl apply --filename=node-exporter-v0.13.yaml --record=true  

2                             kubectl apply --filename=node-exporter-v0.14.yaml --record=true


3                             kubectl apply --filename=node-exporter-bad.yaml --record=true

 ```




Check the details of the revision you want to roll back to:



```  
$ kubectl rollout history ds node-exporter --revision=2  
daemonsets "node-exporter" with revision #2  
Pod Template:  
   Labels:             app=node-exporter  

   Containers:  

     node-exporter:  

       Image:           prom/node-exporter:v0.14.0  

       Port:             9100/TCP  

       Environment:               \<none\>  

       Mounts:         \<none\>  

   Volumes:           \<none\>

 ```




You can quickly roll back to any DaemonSet revision you found through kubectl rollout history:



```  
# Roll back to the last revision

$ kubectl rollout undo ds node-exporter   
daemonset "node-exporter" rolled back


# Or use --to-revision to roll back to a specific revision

$ kubectl rollout undo ds node-exporter --to-revision=2  
daemonset "node-exporter" rolled back
 ```




A DaemonSet rollback is done by rolling forward. Therefore, after the rollback, DaemonSet revision 2 becomes revision 4 (current revision):



```  
$ kubectl rollout history ds node-exporter   
daemonsets "node-exporter"  
REVISION               CHANGE-CAUSE  

1                             kubectl apply --filename=node-exporter-v0.13.yaml --record=true  

3                             kubectl apply --filename=node-exporter-bad.yaml --record=true  

4                             kubectl apply --filename=node-exporter-v0.14.yaml --record=true

 ```




The node exporter DaemonSet is now healthy again:



```  
$ kubectl rollout status ds node-exporter  
daemon set "node-exporter" successfully rolled out


# N = number of nodes

$ kubectl get ds node-exporter

NAME                       DESIRED     CURRENT     READY         UP-TO-DATE     AVAILABLE     NODE SELECTOR     AGE  

Title: Rolling Back a DaemonSet
Summary
This section demonstrates how to roll back a DaemonSet to a previous revision using `kubectl rollout undo`. It shows how to revert to the last known good configuration or a specific revision identified through `kubectl rollout history`. It also clarifies that a DaemonSet rollback is essentially a roll-forward operation, and provides examples of how to check the status of the DaemonSet after the rollback to ensure it's healthy.