Question

Difficulty: MediumDeploying Serverless Applications with Cloud Run and Cloud Functions

A DevOps engineer needs to deploy a new revision of an existing containerized API service to Google Cloud Run. To satisfy testing requirements, the new revision must be deployed without receiving any production user traffic until internal verification is complete. Which command should the engineer execute to deploy the container image while preserving 100% of live traffic on the current revision?

  1. gcloud run deploy api-service --image=gcr.io/my-project/api:v2 --no-trafficAnswer
  2. B
    gcloud run deploy api-service --image=gcr.io/my-project/api:v2 --traffic=0
  3. C
    gcloud run deploy api-service --image=gcr.io/my-project/api:v2 --min-instances=0
  4. D
    gcloud functions deploy api-service --image=gcr.io/my-project/api:v2 --no-traffic

Answer

The command containing `gcloud run deploy api-service --image=gcr.io/my-project/api:v2 --no-traffic` correctly deploys the container revision without directing traffic to it.
Executing `gcloud run deploy` with the `--no-traffic` flag creates the new service revision in Google Cloud Run while retaining 100% of live production traffic on the previously serving revision. This allows developers to safely verify and test the new revision via revision-specific URLs or tags before updating the service traffic split.

Step-by-Step Solution

1
Identify the target serverless compute product
The requirement specifies an existing containerized service deployed to Cloud Run, requiring `gcloud run deploy`.
Cloud Run handles container deployment and service management, whereas Cloud Functions targets function code runtimes.
2
Determine default revision traffic routing behavior in Cloud Run
By default, `gcloud run deploy` routes 100% of traffic to the newly created revision immediately.
Overriding default traffic assignment requires an explicit flag during deployment.
3
Select the correct `gcloud run deploy` flag to suppress traffic allocation
Using `--no-traffic` ensures the revision is created, but receives 0% of traffic, leaving existing traffic splits unchanged.
The `--no-traffic` flag is the built-in mechanism for creating revisions without shifting live production traffic.

Key Concept

Cloud Run Traffic Management during Revision Deployment
Estimated Time:1m 30s
Rate this question