Soru

Zorluk: OrtaDeploying Serverless Applications with Cloud Run and Cloud Functions

An engineer needs to deploy a containerized API microservice to Google Cloud Run using the gcloud CLI. The containerized application is configured to listen internally on custom TCP port 8085, and it must execute using a dedicated user-managed service account named [email protected] to adhere to least privilege permissions. Which TWO gcloud CLI configuration flags must be included in the deployment command to meet these requirements?

  1. Include the --port=8085 flag to instruct Cloud Run to send incoming HTTP requests to port 8085 inside the container.Cevap
  2. Include the --service-account=sa-api-processor@my-project.iam.gserviceaccount.com flag to attach the dedicated identity to the Cloud Run revision.Cevap
  3. C
    Hardcode the PORT environment variable inside the Dockerfile without specifying a port flag during deployment.
  4. D
    Grant the primitive Owner role (roles/owner) to the default Compute Engine service account across the project.

Cevap

The deployment command must include both the --port=8085 flag to route incoming traffic to the container's custom listening port and the --service-account flag to attach the dedicated user-managed service account.
Deploying a Cloud Run service that listens on a non-standard port requires setting the --port flag in the gcloud run deploy command so that ingress traffic is forwarded correctly. Furthermore, specifying the --service-account flag ensures that the service executes under a dedicated user-managed service account rather than the default compute service account.

Adım Adım Çözüm

1
Configure the container ingress port using gcloud run deploy flags.
Adding --port=8085 configures the Cloud Run routing layer to proxy requests to port 8085 inside the container container instance.
By default Cloud Run expects the container to listen on port 8080 unless explicitly overridden via the --port flag.
2
Specify the custom execution identity for the serverless workload.
Adding --service-account=sa-api-processor@my-project.iam.gserviceaccount.com binds the custom IAM service account to the deployed revision.
This ensures the container runs under a non-default identity with minimal required IAM permissions.

Anahtar Kavram

Deploying Cloud Run services with custom port configuration and user-managed service account identities using gcloud CLI.
Tahmini Süre:1m 30s
Bu soruyu puanla