This page shows how to perform a rollback on a DaemonSet.
kubectl
in Kubernetes version 1.7 or later.You can skip this step if you just want to roll back to the last revision.
List all revisions of a DaemonSet:
kubectl rollout history daemonset <daemonset-name>
This returns a list of DaemonSet revisions:
daemonsets "<daemonset-name>"
REVISION CHANGE-CAUSE
1 ...
2 ...
...
kubernetes.io/change-cause
to its revisions upon creation. You may specify --record=true
in kubectl
to record the command executed in the change cause annotation.To see the details of a specific revision:
kubectl rollout history daemonset <daemonset-name> --revision=1
This returns the details of that revision:
daemonsets "<daemonset-name>" with revision #1
Pod Template:
Labels: foo=bar
Containers:
app:
Image: ...
Port: ...
Environment: ...
Mounts: ...
Volumes: ...
# Specify the revision number you get from Step 1 in --to-revision
kubectl rollout undo daemonset <daemonset-name> --to-revision=<revision>
If it succeeds, the command returns:
daemonset "<daemonset-name>" rolled back
If --to-revision
flag is not specified, the last revision will be picked.
kubectl rollout undo daemonset
tells the server to start rolling back the
DaemonSet. The real rollback is done asynchronously on the server side.
To watch the progress of the rollback:
kubectl rollout status ds/<daemonset-name>
When the rollback is complete, the output is similar to this:
daemonset "<daemonset-name>" successfully rolled out
In the previous kubectl rollout history
step, you got a list of DaemonSet
revisions. Each revision is stored in a resource named ControllerRevision
.
ControllerRevision
is a resource only available in Kubernetes release 1.7 or
later.
To see what is stored in each revision, find the DaemonSet revision raw resources:
kubectl get controllerrevision -l <daemonset-selector-key>=<daemonset-selector-value>
This returns a list of ControllerRevisions
:
NAME CONTROLLER REVISION AGE
<daemonset-name>-<revision-hash> DaemonSet/<daemonset-name> 1 1h
<daemonset-name>-<revision-hash> DaemonSet/<daemonset-name> 2 1h
Each ControllerRevision
stores the annotations and template of a DaemonSet
revision.
kubectl rollout undo
takes a specific ControllerRevision
and replaces
DaemonSet template with the template stored in the ControllerRevision
.
kubectl rollout undo
is equivalent to updating DaemonSet template to a
previous revision through other commands, such as kubectl edit
or kubectl
apply
.
Note that DaemonSet revisions only roll forward. That is to say, after a
rollback is complete, the revision number (.revision
field) of the
ControllerRevision
being rolled back to will advance. For example, if you
have revision 1 and 2 in the system, and roll back from revision 2 to revision
1, the ControllerRevision
with .revision: 1
will become .revision: 3
.