Soru

Zorluk: OrtaDeploying Serverless Applications with Cloud Run and Cloud Functions

An engineer is deploying a custom web microservice named `order-processor` to Google Cloud Run using a container image stored in Artifact Registry (`us-docker.pkg.dev/prod-project/apps/order-processor:v1`). The containerized application is hardcoded to listen for HTTP requests on port `3000`. The service must run using a dedicated service account (`[email protected]`) to follow the principle of least privilege, and it must accept public incoming traffic from third-party webhooks without requiring Google IAM authentication. Which `gcloud` command should you run to deploy the service with these specifications?

  1. gcloud run deploy order-processor --image=us-docker.pkg.dev/prod-project/apps/order-processor:v1 [email protected] --allow-unauthenticated --port=3000Cevap
  2. B
    gcloud run deploy order-processor --image=us-docker.pkg.dev/prod-project/apps/order-processor:v1 [email protected] --allow-unauthenticated --set-env-vars=PORT=3000
  3. C
    gcloud functions deploy order-processor --image=us-docker.pkg.dev/prod-project/apps/order-processor:v1 [email protected] --allow-unauthenticated --port=3000
  4. D
    gcloud run deploy order-processor --image=us-docker.pkg.dev/prod-project/apps/order-processor:v1 --role=roles/editor --allow-unauthenticated --port=3000

Cevap

The command starting with 'gcloud run deploy order-processor' with flags '[email protected]', '--allow-unauthenticated', and '--port=3000' correctly deploys the Cloud Run service.
The correct command uses `gcloud run deploy` with `--image` pointing to Artifact Registry, `--service-account` specifying the dedicated identity, `--allow-unauthenticated` for public webhook access, and `--port=3000` to properly instruct Cloud Run to route traffic to the container's custom listening port.

Adım Adım Çözüm

1
Identify the target deployment platform and CLI tool.
Since a custom pre-built container image from Artifact Registry is being deployed as a web service, the correct tool is `gcloud run deploy`.
Cloud Run is designed for deploying pre-packaged container images listening on HTTP.
2
Configure runtime identity and ingress authentication requirements.
Use `[email protected]` to specify the identity and `--allow-unauthenticated` to enable public HTTP access.
This enforces least privilege identity while allowing external webhooks to invoke the HTTP endpoint without IAM credentials.
3
Configure the container port mapping flag.
Use `--port=3000` to inform Cloud Run to send incoming HTTP traffic to port 3000 inside the container.
Cloud Run routes traffic to port 8080 by default. When a container listens on a non-standard port like 3000, `--port=3000` must be explicitly specified during deployment.

Anahtar Kavram

Deploying containerized microservices to Cloud Run with custom port mappings, runtime service accounts, and unauthenticated ingress using gcloud CLI.
Bu soruyu puanla