Merge pull request #21080 from sftim/20200502_tidy_task_daemonset_rollback

Tidy “Perform a Rollback on a DaemonSet”
pull/21701/head
Kubernetes Prow Robot 2020-06-12 22:45:56 -07:00 committed by GitHub
commit 37cd54f9ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 44 deletions

View File

@ -4,29 +4,24 @@ reviewers:
title: Perform a Rollback on a DaemonSet title: Perform a Rollback on a DaemonSet
content_type: task content_type: task
weight: 20 weight: 20
min-kubernetes-server-version: 1.7
--- ---
<!-- overview --> <!-- overview -->
This page shows how to perform a rollback on a DaemonSet. This page shows how to perform a rollback on a {{< glossary_tooltip term_id="daemonset" >}}.
## {{% heading "prerequisites" %}} ## {{% heading "prerequisites" %}}
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
* The DaemonSet rollout history and DaemonSet rollback features are only You should already know how to [perform a rolling update on a
supported in `kubectl` in Kubernetes version 1.7 or later. DaemonSet](/docs/tasks/manage-daemon/update-daemon-set/).
* Make sure you know how to [perform a rolling update on a
DaemonSet](/docs/tasks/manage-daemon/update-daemon-set/).
<!-- steps --> <!-- steps -->
## Performing a Rollback on a DaemonSet ## Performing a rollback on a DaemonSet
### Step 1: Find the DaemonSet revision you want to roll back to ### Step 1: Find the DaemonSet revision you want to roll back to
@ -40,7 +35,7 @@ kubectl rollout history daemonset <daemonset-name>
This returns a list of DaemonSet revisions: This returns a list of DaemonSet revisions:
```shell ```
daemonsets "<daemonset-name>" daemonsets "<daemonset-name>"
REVISION CHANGE-CAUSE REVISION CHANGE-CAUSE
1 ... 1 ...
@ -60,17 +55,17 @@ kubectl rollout history daemonset <daemonset-name> --revision=1
This returns the details of that revision: This returns the details of that revision:
```shell ```
daemonsets "<daemonset-name>" with revision #1 daemonsets "<daemonset-name>" with revision #1
Pod Template: Pod Template:
Labels: foo=bar Labels: foo=bar
Containers: Containers:
app: app:
Image: ... Image: ...
Port: ... Port: ...
Environment: ... Environment: ...
Mounts: ... Mounts: ...
Volumes: ... Volumes: ...
``` ```
### Step 2: Roll back to a specific revision ### Step 2: Roll back to a specific revision
@ -82,16 +77,19 @@ kubectl rollout undo daemonset <daemonset-name> --to-revision=<revision>
If it succeeds, the command returns: If it succeeds, the command returns:
```shell ```
daemonset "<daemonset-name>" rolled back daemonset "<daemonset-name>" rolled back
``` ```
If `--to-revision` flag is not specified, the last revision will be picked. {{< note >}}
If `--to-revision` flag is not specified, kubectl picks the most recent revision.
{{< /note >}}
### Step 3: Watch the progress of the DaemonSet rollback ### Step 3: Watch the progress of the DaemonSet rollback
`kubectl rollout undo daemonset` tells the server to start rolling back the `kubectl rollout undo daemonset` tells the server to start rolling back the
DaemonSet. The real rollback is done asynchronously on the server side. DaemonSet. The real rollback is done asynchronously inside the cluster
{{< glossary_tooltip term_id="control-plane" text="control plane" >}}.
To watch the progress of the rollback: To watch the progress of the rollback:
@ -99,23 +97,19 @@ To watch the progress of the rollback:
kubectl rollout status ds/<daemonset-name> kubectl rollout status ds/<daemonset-name>
``` ```
When the rollback is complete, the output is similar to this: When the rollback is complete, the output is similar to:
```shell ```
daemonset "<daemonset-name>" successfully rolled out daemonset "<daemonset-name>" successfully rolled out
``` ```
<!-- discussion --> <!-- discussion -->
## Understanding DaemonSet Revisions ## Understanding DaemonSet revisions
In the previous `kubectl rollout history` step, you got a list of DaemonSet In the previous `kubectl rollout history` step, you got a list of DaemonSet
revisions. Each revision is stored in a resource named `ControllerRevision`. 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 To see what is stored in each revision, find the DaemonSet revision raw
resources: resources:
@ -124,20 +118,19 @@ resources:
kubectl get controllerrevision -l <daemonset-selector-key>=<daemonset-selector-value> kubectl get controllerrevision -l <daemonset-selector-key>=<daemonset-selector-value>
``` ```
This returns a list of `ControllerRevisions`: This returns a list of ControllerRevisions:
```shell ```
NAME CONTROLLER REVISION AGE NAME CONTROLLER REVISION AGE
<daemonset-name>-<revision-hash> DaemonSet/<daemonset-name> 1 1h <daemonset-name>-<revision-hash> DaemonSet/<daemonset-name> 1 1h
<daemonset-name>-<revision-hash> DaemonSet/<daemonset-name> 2 1h <daemonset-name>-<revision-hash> DaemonSet/<daemonset-name> 2 1h
``` ```
Each `ControllerRevision` stores the annotations and template of a DaemonSet Each ControllerRevision stores the annotations and template of a DaemonSet
revision. The name of a ControllerRevision object must be a valid revision.
[DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
`kubectl rollout undo` takes a specific `ControllerRevision` and replaces `kubectl rollout undo` takes a specific ControllerRevision and replaces
DaemonSet template with the template stored in the `ControllerRevision`. DaemonSet template with the template stored in the ControllerRevision.
`kubectl rollout undo` is equivalent to updating DaemonSet template to a `kubectl rollout undo` is equivalent to updating DaemonSet template to a
previous revision through other commands, such as `kubectl edit` or `kubectl previous revision through other commands, such as `kubectl edit` or `kubectl
apply`. apply`.
@ -145,16 +138,12 @@ apply`.
{{< note >}} {{< note >}}
DaemonSet revisions only roll forward. That is to say, after a DaemonSet revisions only roll forward. That is to say, after a
rollback completes, the revision number (`.revision` field) of the rollback completes, the revision number (`.revision` field) of the
`ControllerRevision` being rolled back to will advance. For example, if you 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 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`. 1, the ControllerRevision with `.revision: 1` will become `.revision: 3`.
{{< /note >}} {{< /note >}}
## Troubleshooting ## Troubleshooting
* See [troubleshooting DaemonSet rolling * See [troubleshooting DaemonSet rolling
update](/docs/tasks/manage-daemon/update-daemon-set/#troubleshooting). update](/docs/tasks/manage-daemon/update-daemon-set/#troubleshooting).