Soru

Zorluk: OrtaDeploying Serverless Applications with Cloud Run and Cloud Functions

A microservices developer needs to deploy a containerized application stored in Artifact Registry (`europe-west1-docker.pkg.dev/company-prod/apps/payment-gateway:v1`) to Google Cloud Run. The deployment must fulfill the following operational criteria:
- Deploy the service under the name `payment-gateway` in the `europe-west1` region.
- Run the container using the custom service account `[email protected]`.
- Allow public HTTP requests without authentication for incoming webhooks.

Which `gcloud` command should the developer execute to meet these requirements?

  1. gcloud run deploy payment-gateway --image=europe-west1-docker.pkg.dev/company-prod/apps/payment-gateway:v1 --region=europe-west1 --service-account=payment-sa@company-prod.iam.gserviceaccount.com --allow-unauthenticatedCevap
  2. B
    gcloud functions deploy payment-gateway --image=europe-west1-docker.pkg.dev/company-prod/apps/payment-gateway:v1 --region=europe-west1 --service-account=payment-sa@company-prod.iam.gserviceaccount.com --allow-unauthenticated
  3. C
    gcloud run deploy payment-gateway --image=europe-west1-docker.pkg.dev/company-prod/apps/payment-gateway:v1 --region=europe-west1 --service-account=payment-sa@company-prod.iam.gserviceaccount.com --allow-unauthenticated --port=80
  4. D
    gcloud run deploy payment-gateway --image=europe-west1-docker.pkg.dev/company-prod/apps/payment-gateway:v1 --region=europe-west1 --role=roles/owner --allow-unauthenticated

Cevap

The command starting with `gcloud run deploy payment-gateway` with `--image`, `--region=europe-west1`, `--service-account`, and `--allow-unauthenticated` flags correctly deploys the Cloud Run service.
The correct command uses `gcloud run deploy payment-gateway` combined with `--image` pointing to Artifact Registry, specifies `--region=europe-west1` for target location, configures `--service-account` for identity, and includes `--allow-unauthenticated` to permit unauthenticated external webhook invocations.

Adım Adım Çözüm

1
Identify the proper Google Cloud compute platform for deploying custom container images.
Cloud Run is the appropriate serverless service for running arbitrary container images, using `gcloud run deploy`.
Cloud Functions deploys function source code, whereas Cloud Run deploys stateless container images.
2
Select the required deployment flags for service name, image path, region, execution identity, and ingress authentication.
The flags `--image`, `--region=europe-west1`, `--service-account=payment-sa@company-prod.iam.gserviceaccount.com`, and `--allow-unauthenticated` satisfy all requirements.
These flags specify where to fetch the container image, where to run it, under which IAM service account identity it runs, and whether unauthenticated web traffic is permitted.
3
Verify port configuration best practices for Cloud Run.
Avoid setting `--port=80` unless the container explicitly requires listening on port 80 instead of the standard `$PORT` (8080).
Cloud Run injects the `PORT` environment variable (default 8080) into the container container environment.

Anahtar Kavram

Deploying serverless container workloads to Cloud Run using gcloud CLI flags
Tahmini Süre:1m 30s
Bu soruyu puanla