Soru

Zorluk: Çok zorDeploying Serverless Applications with Cloud Run and Cloud Functions

A senior DevOps engineer is managing a stateless containerized web service deployed on Google Cloud Run in the us-central1 region. The existing service named order-processor currently has all production traffic (100%) routed to revision order-processor-v1. To conduct a canary deployment of a newly built container image, the engineer successfully deploys the new code without shifting live traffic by running gcloud run deploy order-processor --image=gcr.io/corp-apps/order-processor:v2 --region=us-central1 --no-traffic. This deployment generates a new revision named order-processor-v2. The engineer now needs to safely route exactly 20% of incoming live HTTP requests to order-processor-v2 while maintaining the remaining 80% on order-processor-v1. Which gcloud command should the engineer execute to achieve this traffic distribution?

  1. Execute gcloud run services update-traffic order-processor --region=us-central1 --to-revisions=order-processor-v2=20.Cevap
  2. B
    Re-run gcloud run deploy order-processor --image=gcr.io/corp-apps/order-processor:v2 --region=us-central1 --traffic-split=order-processor-v2=20.
  3. C
    Assign the roles/editor primitive role to the default Compute Engine service account so IAM policy rules can automatically rebalance load across active revisions.
  4. D
    Redeploy the application to Cloud Functions (2nd gen) using gcloud functions deploy order-processor --split-traffic=order-processor-v2=20 because Cloud Run revisions cannot share live HTTP traffic.

Cevap

Execute gcloud run services update-traffic order-processor --region=us-central1 --to-revisions=order-processor-v2=20.
The command gcloud run services update-traffic order-processor --region=us-central1 --to-revisions=order-processor-v2=20 is the official GCP CLI method to update traffic assignments. When targeting a single revision with a partial percentage (such as 20%), Cloud Run allocates that percentage to the new revision while preserving the remaining proportion (80%) on the previously serving revision.

Adım Adım Çözüm

1
Identify the current state of Cloud Run revisions.
Revision order-processor-v1 holds 100% traffic, and revision order-processor-v2 is deployed with 0% traffic using --no-traffic.
Deploying with --no-traffic provisions a new revision without shifting live production requests.
2
Select the correct gcloud command tool for Cloud Run traffic allocation.
The gcloud run services update-traffic command is designed specifically to modify traffic splitting percentages across revisions.
Deploying code updates and managing operational traffic splits are separate actions in the Cloud Run CLI lifecycle.
3
Apply the target revision percentage flag.
Specifying --to-revisions=order-processor-v2=20 assigns 20% to order-processor-v2 and automatically maintains the remaining 80% on order-processor-v1.
Cloud Run automatically scales down remaining unspecified baseline traffic to balance total allocation to 100%.

Anahtar Kavram

Cloud Run Revision Traffic Splitting and Canary Deployments
Bu soruyu puanla