Goglides Dev 🌱

Balkrishna Pandey
Balkrishna Pandey

Posted on • Updated on

Checking Rollout History/ Rollback of a Deployment

One useful feature of deployments is the ability to track the rollout history. To view rollout history, use the following command:

kubectl rollout history deployment/nginx
Enter fullscreen mode Exit fullscreen mode

You will see output something similar to this.

deployment.apps/nginx 
REVISION CHANGE-CAUSE
1     <none>
2     <none>
3     <none>
Enter fullscreen mode Exit fullscreen mode

We can get details on a particular revision with:

kubectl rollout history deployment.v1.apps/nginx --revision=1
Enter fullscreen mode Exit fullscreen mode

Output:

deployment.apps/nginx with revision #1
Pod Template:
 Labels:    app=frontend
    pod-template-hash=776567f984
 Containers:
  nginx:
  Image:    nginx:latest
  Port: 80/TCP
  Host Port:    0/TCP
  Environment:  <none>
  Mounts:   <none>
 Volumes:   <none>
Enter fullscreen mode Exit fullscreen mode

Rolling Back a Deployment

Suppose you have made some changes to your deployment that you want to roll back. To do this, use the following command:

kubectl rollout undo deployment/nginx --to-revision=3
Enter fullscreen mode Exit fullscreen mode

Output:

deployment.apps/nginx rolled back
Enter fullscreen mode Exit fullscreen mode

Also check the pods list, you will see following output, where deployment controller trying to reconcile the status.

kubectl get pods -l app=frontend           
NAME           READY  STATUS       RESTARTS  AGE
nginx-68d45cc4b6-cm2hz  1/1   Running       0     85s
nginx-68d45cc4b6-dkwd8  1/1   Running       0     81s
nginx-68d45cc4b6-pzkx7  1/1   Running       0     85s
nginx-68d45cc4b6-znqgn  1/1   Terminating     0     82s
nginx-74bb7f5f9f-ds8qs  0/1   ContainerCreating  0     2s
nginx-74bb7f5f9f-g4nqq  1/1   Running       0     2s
nginx-74bb7f5f9f-rdl5h  0/1   Pending       0     0s
nginx-74bb7f5f9f-rrbfs  0/1   ContainerCreating  0     2s
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
jeewangautam profile image
Jeewan Gautam

Very helpful materials.