An engineer is deploying a custom web microservice named `order-processor` to Google Cloud Run using a container image stored in Artifact Registry (`us-docker.pkg.dev/prod-project/apps/order-processor:v1`). The containerized application is hardcoded to listen for HTTP requests on port `3000`. The service must run using a dedicated service account (`[email protected]`) to follow the principle of least privilege, and it must accept public incoming traffic from third-party webhooks without requiring Google IAM authentication. Which `gcloud` command should you run to deploy the service with these specifications?
- gcloud run deploy order-processor --image=us-docker.pkg.dev/prod-project/apps/order-processor:v1 [email protected] --allow-unauthenticated --port=3000Answer
- Bgcloud run deploy order-processor --image=us-docker.pkg.dev/prod-project/apps/order-processor:v1 [email protected] --allow-unauthenticated --set-env-vars=PORT=3000
- Cgcloud functions deploy order-processor --image=us-docker.pkg.dev/prod-project/apps/order-processor:v1 [email protected] --allow-unauthenticated --port=3000
- Dgcloud run deploy order-processor --image=us-docker.pkg.dev/prod-project/apps/order-processor:v1 --role=roles/editor --allow-unauthenticated --port=3000
Answer
The command starting with 'gcloud run deploy order-processor' with flags '[email protected]', '--allow-unauthenticated', and '--port=3000' correctly deploys the Cloud Run service.
The correct command uses `gcloud run deploy` with `--image` pointing to Artifact Registry, `--service-account` specifying the dedicated identity, `--allow-unauthenticated` for public webhook access, and `--port=3000` to properly instruct Cloud Run to route traffic to the container's custom listening port.
Step-by-Step Solution
Key Concept
Deploying containerized microservices to Cloud Run with custom port mappings, runtime service accounts, and unauthenticated ingress using gcloud CLI.