|
|
ADK Blue-Green Deployments
Author: Venkata Sudhakar
Blue-green deployment keeps two identical production environments - the live (blue) version serving all traffic and a new (green) version ready to receive traffic. When the green version passes validation, traffic is switched over instantly. If the green version has issues, the switch back to blue takes seconds with no downtime. ShopMax India uses this pattern when releasing updated versions of the order support agent with new prompts or tool changes.
Cloud Run makes blue-green deployments straightforward. Each deployment creates a new revision, and Cloud Run traffic management allows traffic to be split between revisions or fully switched at any time using the gcloud CLI. The old revision remains live until explicitly deleted, making instant rollback possible without a re-deploy.
The below example shows how to deploy a new green revision, validate it, then cut over all traffic from blue to green.
It gives the following output,
Deploying container to Cloud Run service [shopmax-support-agent]...
New revision [shopmax-support-agent-00042-xyz] deployed (0% traffic).
Tagged as: green
Green URL: https://green---shopmax-support-agent-xxxx.run.app
Validation response: {"reply": "We have 12 laptop models in stock..."}
Traffic updated:
shopmax-support-agent-00042-xyz: 100% (green - new)
shopmax-support-agent-00041-abc: 0% (blue - previous)
Automate the blue-green pipeline in Cloud Build: the build step deploys the new revision with no traffic, the test step runs integration tests against the tagged URL, and the promote step moves traffic to 100% only when tests pass. Add a Cloud Monitoring alert that auto-rollbacks traffic to the previous revision if error rate exceeds 1% within 5 minutes of promotion, giving ShopMax a fully automated safety net for every release.
|
|