An enterprise online reservation platform hosts its core booking microservice on Google Kubernetes Engine (GKE) backed by a Cloud SQL for PostgreSQL database. The platform team needs to execute a zero-downtime release featuring a major application update and a breaking database schema migration. What is the correct sequence of steps to safely execute this blue-green deployment without service disruption or data corruption?
- 1Execute an 'expand' database migration script to add new columns and tables while retaining all existing columns, constraints, and triggers.
- 2Deploy the new application pods (Green deployment) into the GKE cluster alongside the active (Blue) deployment while keeping 100% of ingress traffic directed to Blue.
- 3Update the GKE Gateway API HTTPRoute resource to shift 100% of live user traffic from the Blue deployment to the Green deployment.
- 4Execute a 'contract' database migration script to drop obsolete columns and legacy schema objects once Green stability is verified and Blue pods are decommissioned.
Answer
The correct sequence of steps is: 1) Execute the expand database migration to add new schema elements without breaking existing logic, 2) Deploy the Green microservice revision to GKE while keeping live traffic on Blue, 3) Update the HTTPRoute resource to shift traffic to Green, and 4) Execute the contract database migration to clean up legacy schema objects once Green stability is confirmed.
Executing a zero-downtime release with breaking database schema changes requires decoupled, backwards-compatible deployment phases. First, the database schema must be expanded by adding new columns as nullable or with defaults, allowing the running Blue version to operate uninterrupted. Next, the Green workload is deployed in parallel on GKE to verify its readiness. Traffic is then shifted instantly using GKE routing controls. Finally, after validating the Green release and draining Blue connections, a contract migration safely removes the legacy database columns.
Step-by-Step Solution
Key Concept
Expand-Contract Database Migration Pattern in Blue-Green Deployments