DEV Community

Cover image for Part-89: πŸ”„ Kubernetes Deployments: Rollbacks & Rolling Restarts in GCP (Google Kubernetes Engine)
Latchu@DevOps
Latchu@DevOps

Posted on

Part-89: πŸ”„ Kubernetes Deployments: Rollbacks & Rolling Restarts in GCP (Google Kubernetes Engine)

Kubernetes Deployments: Rollbacks & Rolling Restarts

In this guide, we’ll learn how to:

  • Rollback a Deployment to a previous version
  • Rollback to a specific revision
  • Perform Rolling Restarts of an application

By the end, you’ll understand how Kubernetes ensures safe rollbacks and seamless restarts with zero downtime.


πŸ“Œ Step 00: Introduction

Kubernetes provides two main rollback strategies:

  • Rollback to Previous Version β†’ Quickly revert to the last known good state.
  • Rollback to Specific Revision β†’ Revert to any earlier revision tracked in rollout history.

Additionally, Rolling Restarts allow you to restart pods in a controlled, zero-downtime manner.


πŸ”Ή Step 01: Rollback Deployment to Previous Version

1️⃣ Check Rollout History

kubectl rollout history deployment/my-first-deployment
Enter fullscreen mode Exit fullscreen mode

d1

2️⃣ Review Each Revision

Check annotations and images used in previous revisions.

kubectl rollout history deployment/my-first-deployment --revision=1
kubectl rollout history deployment/my-first-deployment --revision=2
kubectl rollout history deployment/my-first-deployment --revision=3
Enter fullscreen mode Exit fullscreen mode

d2


3️⃣ Rollback to Previous Version

This will rollback to the last working revision.

kubectl rollout undo deployment/my-first-deployment
Enter fullscreen mode Exit fullscreen mode

Verify history again:

kubectl rollout history deployment/my-first-deployment
Enter fullscreen mode Exit fullscreen mode

πŸ“Œ Observation: The rollback creates a new revision (example: rollback from v3 β†’ v2 becomes revision 4).

d3


4️⃣ Verify Deployment, Pods, and ReplicaSets

kubectl get deploy
kubectl get rs
kubectl get po
kubectl describe deploy my-first-deployment
Enter fullscreen mode Exit fullscreen mode

d4


5️⃣ Access Application via Public IP

kubectl get svc
http://<External-IP>
Enter fullscreen mode Exit fullscreen mode

βœ… You should see Application Version: V2.

d5


πŸ”Ή Step 02: Rollback Deployment to a Specific Revision

1️⃣ Check Rollout History

kubectl rollout history deployment/my-first-deployment
Enter fullscreen mode Exit fullscreen mode

2️⃣ Rollback to a Specific Revision (Example: Revision 3)

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

3️⃣ Verify History

kubectl rollout history deployment/my-first-deployment
Enter fullscreen mode Exit fullscreen mode

πŸ“Œ Observation: Rolling back to revision 3 creates a new revision 5 entry in rollout history.

d6


4️⃣ Access Application via Public IP

kubectl get svc
http://<External-IP>
Enter fullscreen mode Exit fullscreen mode

βœ… You should now see Application Version: V3.


d7


πŸ”Ή Step 03: Rolling Restarts of Application

Sometimes you just need to restart all Pods without changing the image. Rolling restarts replace Pods one by one, avoiding downtime.

# Rolling Restart
kubectl rollout restart deployment/my-first-deployment

# Verify Pods are being recreated
kubectl get po
Enter fullscreen mode Exit fullscreen mode

πŸ“Œ Observation: Old Pods terminate gracefully, and new Pods come online one by one.

d8


βœ… Recap

In this guide, we covered:

  • Rollback to previous version β†’ Fast recovery from failures
  • Rollback to specific revision β†’ Granular control with revision history
  • Rolling restarts β†’ Safely refresh all Pods without downtime

🎯 With Kubernetes in GCP, you get built-in resilience, fast recovery, and seamless restarts.


🌟 Thanks for reading! If this post added value, a like ❀️, follow, or share would encourage me to keep creating more content.


β€” Latchu | Senior DevOps & Cloud Engineer

☁️ AWS | GCP | ☸️ Kubernetes | πŸ” Security | ⚑ Automation
πŸ“Œ Sharing hands-on guides, best practices & real-world cloud solutions

Top comments (0)