GCP Associate Cloud Engineer Practice Question 57: Cloud Run Canary Traffic Split
Google Cloud Associate Cloud Engineer · Test 6 · question 7 of 10
A team runs a Cloud Run service that is already serving 100% of its traffic on the current revision. They built a new container image with a bug fix and want to verify it in production with a small slice of real traffic before it takes over completely. If the new revision looks healthy, they will keep increasing its share until it serves all requests; if it misbehaves, they want to shift traffic back to the current revision immediately without deploying anything new. They need to do this using only gcloud.
Which approach meets these requirements?
Show answer and explanation
Answer:
Cloud Run lets a single service route traffic across multiple revisions. Deploying with --no-traffic creates the new revision without touching the existing split, so the current revision keeps serving all requests while the new one is verified. gcloud run services update-traffic SERVICE --to-revisions REVISION=PERCENT then assigns the new revision a small percentage (for example 5%), and the same command can be run again with a higher percentage to ramp up, or with the old revision set back to 100% to roll back instantly, all without a new deploy.
Option A is wrong because a plain gcloud run deploy routes 100% of traffic to the new revision immediately, giving no canary period, and rolling back means redeploying the old image rather than an instant traffic switch. Option C and D add unnecessary infrastructure: Cloud Run already supports revision-level traffic splitting natively, so standing up a second service behind an external load balancer, or duplicating the deployment across regions behind a global load balancer, is more complex and does not use the built-in mechanism the scenario calls for.
Reference: Rollbacks, gradual rollouts, and traffic migration