Soru

Zorluk: ZorDeploying Serverless Applications with Cloud Run and Cloud Functions

An infrastructure team is deploying two serverless microservices to Google Cloud using the gcloud CLI:

1. A containerized backend service deployed to Cloud Run that listens internally on custom TCP port 9090.
2. A lightweight HTTP-triggered webhook processing service deployed as a Cloud Functions (2nd gen) service.

Which TWO configuration choices or gcloud command options must be specified to successfully deploy these serverless applications? (Select TWO.)

  1. Pass the `--port=9090` flag during `gcloud run deploy` so Cloud Run routes incoming HTTP requests to the container's custom listening port.Cevap
  2. B
    Hardcode the environment variable `PORT=8080` inside the container Dockerfile and rely on Cloud Run to automatically translate incoming traffic from port 9090.
  3. Execute `gcloud functions deploy` specifying `--gen2` and `--trigger-http` to deploy the webhook processor as a 2nd gen function.Cevap
  4. D
    Execute `gcloud functions deploy` with the `--image` flag pointing to an Artifact Registry container image to deploy multi-container serverless applications.

Cevap

The correct configurations are specifying `--port=9090` in `gcloud run deploy` to instruct Cloud Run to forward ingress traffic to custom port 9090, and executing `gcloud functions deploy` with `--gen2` and `--trigger-http` for the 2nd gen HTTP Cloud Function.
Specifying `--port=9090` during Cloud Run deployment explicitly configures the platform to route incoming HTTP requests to port 9090 inside the container. Additionally, deploying an HTTP-triggered 2nd gen Cloud Function requires `gcloud functions deploy` with the `--gen2` and `--trigger-http` flags.

Adım Adım Çözüm

1
Analyze Cloud Run port binding requirements for custom container images.
Cloud Run expects containers to listen on the port defined by the `PORT` environment variable (defaulting to 8080). If the application binary listens on custom port 9090, specifying `--port=9090` during `gcloud run deploy` tells Cloud Run which port to target.
Prevents port mismatch errors and ensures successful health checks.
2
Identify the standard CLI invocation for deploying Cloud Functions 2nd gen HTTP services.
Executing `gcloud functions deploy [FUNCTION_NAME] --gen2 --trigger-http` deploys the function source to the 2nd gen runtime backed by Cloud Run and Eventarc.
Matches the required gcloud syntax for 2nd gen HTTP event handlers.

Anahtar Kavram

Deploying serverless applications using Cloud Run custom port configurations and Cloud Functions (2nd gen) CLI deployment flags
Tahmini Süre:2m 0s
Bu soruyu puanla