Software Development

How to handle Blue Green Deployment rollbacks effectively using Kubernetes and CI CD?

KE Asked by Kevin Patterson · 05-05-2024
0 upvotes 15,236 views 0 comments
The question

We are moving our microservices architecture to Kubernetes and want to implement Blue-Green deployments to minimize downtime. However, I am confused about the rollback strategy if a bug is detected post-deployment. If the 'Green' environment is live and fails, what is the fastest way to point the traffic back to 'Blue' without causing a service interruption? Also, how do you handle database schema changes during this process, as the DB is usually shared between both environments?

 

3 answers

0
BA
Answered on 07-05-2024

In Kubernetes, the fastest way to handle a Blue-Green rollback is by updating the Service selector. Your 'Service' object points to a specific set of Pod labels. To roll back, you simply use kubectl apply or a Helm chart update to change the selector back to the 'Blue' version labels. This change happens almost instantaneously at the networking layer. Regarding databases, the industry standard is "Expand and Contract" migration. First, apply schema changes that are backward compatible with the old code. Once the Green version is stable, you can then remove the old, unused columns or tables.

0
ST
Answered on 10-05-2024

Are you currently using an Ingress Controller like Nginx or a Service Mesh like Istio to manage your traffic splitting between these two environments? 

TH 11-05-2024

Steven, we are using Nginx Ingress currently. It allows us to use "canary annotations" to send 10% of traffic to the Green pods before we do the full switch. If our Prometheus metrics show high error rates during that 10% phase, our CI/CD tool (GitLab CI) automatically stops the rollout. This prevents a total site outage and makes the "rollback" a simple matter of deleting the temporary canary ingress rule.

0
L
Answered on 14-05-2024

The key is keeping the "Blue" environment alive until you are 100% sure the "Green" one is stable. Don't kill those old pods too early or you lose your fallback! 

KE 15-05-2024

Exactly, Laura. We usually keep the Blue pods running for at least 30 minutes after the switch. It costs a bit more in cloud resources, but the peace of mind is worth every penny.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

Book Free Session