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?
- Include the --port=8085 flag to instruct Cloud Run to send incoming HTTP requests to port 8085 inside the container.Answer
- Include the --service-account=sa-api-processor@my-project.iam.gserviceaccount.com flag to attach the dedicated identity to the Cloud Run revision.Answer
- CHardcode the PORT environment variable inside the Dockerfile without specifying a port flag during deployment.
- DGrant the primitive Owner role (roles/owner) to the default Compute Engine service account across the project.
Answer
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.
Step-by-Step Solution
Key Concept
Deploying Cloud Run services with custom port configuration and user-managed service account identities using gcloud CLI.
Estimated Time:1m 30s