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)