Rolling back a deployment

This recipe will take you through the instructions for reviewing changes made by comparing the annotations and rolling back the Deployment to an older revision when needed.

Let's perform the following steps:

  1. Check the details and events for the Deployment and note recent ScalingReplicaSet events:
$ kubectl describe deployments
  1. Now, display the rollout history for the Deployment. The output will show the revisions along with the annotations we have created:
$ kubectl rollout history deployment nginx-deployment
deployment.extensions/nginx-deployment
REVISION CHANGE-CAUSE
1 <none>
2 image updated to 1.16.0
3 image updated to 1.17.0 and scaled up to 3 replicas
  1. Roll back the last rollout. This command will take your Deployment to the previous revision, in this recipe, revision 2:
$ kubectl rollout undo deployment nginx-deployment
deployment.apps/nginx-deployment rolled back
  1. Confirm that the Deployment has rolled back to the previous version:
$ kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-deployment-5c689d88bb 0 0 0 69m
nginx-deployment-5d599789c6 0 0 0 12m
nginx-deployment-f98cbd66f 3 3 3 33m
Notice that the rollback command only takes the Deployments back to different image version rollouts, and does not undo the other spec changes, such as the number of replicas.
  1. Now, roll back to a specific revision. This command will take your Deployment to a specific revision defined using the --to-revision parameter:
$ kubectl rollout undo deployment nginx-deployment --to-revision=1

Now you have learned how to review the rollout history and roll back a change when required.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.20.231