Question

Difficulty: MediumDeploying Serverless Applications with Cloud Run and Cloud Functions

A solution architect needs to deploy a web microservice stored as a container image in Artifact Registry (`us-central1-docker.pkg.dev/my-project/apps/order-api:v1`) to Google Cloud Run. The deployment must meet the following requirements:
- The service name must be `order-api`.
- It must be deployed to the `us-central1` region.
- It must pass an environment variable `DB_HOST=10.0.0.5` to the application container.
- It must allow incoming public HTTP requests without authentication.

Which `gcloud` command correctly accomplishes this deployment?

  1. gcloud run deploy order-api --image=us-central1-docker.pkg.dev/my-project/apps/order-api:v1 --region=us-central1 --set-env-vars=DB_HOST=10.0.0.5 --allow-unauthenticatedAnswer
  2. B
    gcloud functions deploy order-api --image=us-central1-docker.pkg.dev/my-project/apps/order-api:v1 --region=us-central1 --set-env-vars=DB_HOST=10.0.0.5 --allow-unauthenticated
  3. C
    gcloud run deploy order-api --image=us-central1-docker.pkg.dev/my-project/apps/order-api:v1 --zone=us-central1-a --set-env-vars=DB_HOST=10.0.0.5 --allow-unauthenticated
  4. D
    gcloud run deploy order-api --image=us-central1-docker.pkg.dev/my-project/apps/order-api:v1 --region=us-central1 --set-env-vars=DB_HOST=10.0.0.5 --no-allow-unauthenticated

Answer

The correct command uses 'gcloud run deploy order-api' with '--image=us-central1-docker.pkg.dev/my-project/apps/order-api:v1', '--region=us-central1', '--set-env-vars=DB_HOST=10.0.0.5', and '--allow-unauthenticated'.
The command correctly uses the 'gcloud run deploy' surface to target Cloud Run, supplies the container image URL via the '--image' flag, designates the target region with '--region=us-central1', sets runtime environment variables using '--set-env-vars', and explicitly enables public HTTP ingress via '--allow-unauthenticated'.

Step-by-Step Solution

1
Identify the target serverless compute product.
Cloud Run is required because the workload is supplied as a container image.
Cloud Run is designed for stateless container execution, whereas Cloud Functions targets code snippets.
2
Select the correct location and environment flags for Cloud Run.
Cloud Run services are regional resources, so '--region=us-central1' is required instead of zonal flags.
Specifying '--zone' causes a gcloud CLI syntax error for Cloud Run deployment commands.
3
Verify access control requirements.
The flag '--allow-unauthenticated' enables public HTTP traffic without requiring IAM authentication tokens.
Using '--no-allow-unauthenticated' restricts access to authenticated identity tokens.

Key Concept

Cloud Run Service Deployment CLI Syntax
Estimated Time:1m 35s
Rate this question