Rollback a Deployment in Kubernetes

Ticker

6/recent/ticker-posts

Rollback a Deployment in Kubernetes

Question : This morning the Nautilus DevOps team rolled out a new release for one of the applications. Recently on of the customers logged a complaint which seems to be about a bug related to the recent release. Therefore, the team wants to roll back the recent release.

There is a deployment named nginx-deployment; roll it back to the previous revision.

Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.



Please Note :-  Perform the below commands based on your question  server,  user name & other details might differ . So please read task carefully before executing. All the Best 👍

 Solution :
 

1. At first  check existing deployment and pods running status     

thor@jump_host /$ kubectl get deploy

NAME               READY   UP-TO-DATE   AVAILABLE   AGE

nginx-deployment   3/3     3            3           63s

thor@jump_host /$

thor@jump_host /$ kubectl get pods

NAME                                READY   STATUS    RESTARTS   AGE

nginx-deployment-5546d5b87b-5p92f   1/1     Running   0          51s

nginx-deployment-5546d5b87b-8ggrx   1/1     Running   0          48s

nginx-deployment-5546d5b87b-bfqp9   1/1     Running   0          59s

thor@jump_host /$

 2. Run the below command to revert to an earlier release 

    ( refer to Video below for better understanding)    

thor@jump_host /$ kubectl rollout undo deployment  nginx-deployment

deployment.apps/nginx-deployment rolled back

thor@jump_host /$


3. Wait for deployment & pods to get running status
    

thor@jump_host /$ kubectl get deploy

NAME               READY   UP-TO-DATE   AVAILABLE   AGE

nginx-deployment   3/3     2            3           3m41s

thor@jump_host /$

thor@jump_host /$ kubectl get pods

NAME                                READY   STATUS        RESTARTS   AGE

nginx-deployment-5546d5b87b-5p92f   0/1     Terminating   0          3m31s

nginx-deployment-5546d5b87b-bfqp9   0/1     Terminating   0          3m39s

nginx-deployment-74fb588559-594j5   1/1     Running       0          12s

nginx-deployment-74fb588559-ms48l   1/1     Running       0          9s

nginx-deployment-74fb588559-vvqsr   1/1     Running       0          14s

thor@jump_host /$

thor@jump_host /$ kubectl get deploy

NAME               READY   UP-TO-DATE   AVAILABLE   AGE

nginx-deployment   3/3     3            3           5m8s

thor@jump_host /$ kubectl get pods

NAME                                READY   STATUS    RESTARTS   AGE

nginx-deployment-74fb588559-594j5   1/1     Running   0          93s

nginx-deployment-74fb588559-ms48l   1/1     Running   0          90s

nginx-deployment-74fb588559-vvqsr   1/1     Running   0          95s

thor@jump_host /$

4. Validate the task by running the below command

thor@jump_host /$ kubectl rollout status deployment  nginx-deployment

deployment "nginx-deployment" successfully rolled out

thor@jump_host /$

5.  Click on Finish & Confirm to complete the task successful

Happy Learning!!!!

Apart from this if you need more clarity,  I have made a  tutorial video on this, please go through and share your comments. Like and share the knowledge



Post a Comment

0 Comments

Latest Posts

KodeKloud Kubernetes Security CKS  Lab Challenge 4 |  Audit-policy | Install & configure falco utility | Inspect the API server audit logs and identify the user