A software engineering team built a Node.js microservice packaged as a custom container image stored in Artifact Registry. The internal web server application inside the container is explicitly configured to listen on port 5000. The team must deploy this service to Cloud Run in region us-central1 using a custom identity service account named [email protected] and ensure that unauthenticated requests are blocked. Which gcloud command should be executed to accomplish this deployment?
- gcloud run deploy node-api --image=us-central1-docker.pkg.dev/company-project/apps/node-api:v1 --port=5000 --service-account=api-runner@company-project.iam.gserviceaccount.com --no-allow-unauthenticated --region=us-central1Answer
- Bgcloud run deploy node-api --image=us-central1-docker.pkg.dev/company-project/apps/node-api:v1 --service-account=api-runner@company-project.iam.gserviceaccount.com --no-allow-unauthenticated --region=us-central1
- Cgcloud functions deploy node-api --image=us-central1-docker.pkg.dev/company-project/apps/node-api:v1 --service-account=api-runner@company-project.iam.gserviceaccount.com --region=us-central1
- Dgcloud run deploy node-api --image=us-central1-docker.pkg.dev/company-project/apps/node-api:v1 --port=5000 --service-account=project-owner@company-project.iam.gserviceaccount.com --allow-unauthenticated --region=us-central1
Answer
The command 'gcloud run deploy node-api --image=us-central1-docker.pkg.dev/company-project/apps/node-api:v1 --port=5000 --service-account=api-runner@company-project.iam.gserviceaccount.com --no-allow-unauthenticated --region=us-central1' correctly configures the non-default port 5000, attaches the designated service account, and enforces authentication requirements.
The correct command explicitly sets the container port to 5000 via '--port=5000', matching the internal port of the web server. It also correctly attaches the designated custom service account and includes '--no-allow-unauthenticated' to enforce authentication controls.
Step-by-Step Solution
Key Concept
Configuring custom container port bindings and execution identities when deploying Cloud Run services via gcloud CLI.