Question

Difficulty: HardDeploying Serverless Applications with Cloud Run and Cloud Functions

An enterprise migration team has packaged an multi-endpoint REST microservice into a custom container image named `gcr.io/my-project/orders-api:v1`. The web server inside the container is explicitly compiled to listen on internal TCP port `3000` rather than reading standard environment defaults. The deployment requirements mandate using a serverless execution model with a custom identity service account (`[email protected]`) for fine-grained GCP resource access, while allowing unauthenticated public HTTPS ingress. Which `gcloud` command must a Cloud Engineer execute to successfully deploy this application to Cloud Run?

  1. gcloud run deploy orders-api --image=gcr.io/my-project/orders-api:v1 --port=3000 --service-account=orders-identity@my-project.iam.gserviceaccount.com --allow-unauthenticated --region=us-central1Answer
  2. B
    gcloud functions deploy orders-api --image=gcr.io/my-project/orders-api:v1 --port=3000 --service-account=orders-identity@my-project.iam.gserviceaccount.com --allow-unauthenticated --region=us-central1
  3. C
    gcloud run deploy orders-api --image=gcr.io/my-project/orders-api:v1 --service-account=orders-identity@my-project.iam.gserviceaccount.com --allow-unauthenticated --region=us-central1
  4. D
    gcloud run deploy orders-api --image=gcr.io/my-project/orders-api:v1 --port=3000 --role=roles/owner --allow-unauthenticated --region=us-central1

Answer

The command starting with `gcloud run deploy orders-api --image=gcr.io/my-project/orders-api:v1 --port=3000` correctly provisions a Cloud Run service listening on internal port 3000 with the specified runtime service account and unauthenticated access.
Deploying a containerized web application listening on custom port 3000 requires `gcloud run deploy` combined with `--port=3000`, `--service-account`, and `--allow-unauthenticated`. This ensures correct traffic forwarding, appropriate identity management, and public ingress access.

Step-by-Step Solution

1
Select the appropriate GCP serverless service for custom container images with multi-endpoint web APIs.
Identify Cloud Run (`gcloud run deploy`) as the correct execution paradigm instead of Cloud Functions.
Cloud Run is optimized for stateless containerized web applications listening on HTTP/HTTPS ports.
2
Configure internal container port routing.
Include the `--port=3000` flag in the deployment invocation.
Cloud Run defaults to forwarding ingress requests to port `8080`. When a container server strictly listens on custom port `3000`, the `--port` flag overrides the default `PORT` environment variable contract.
3
Attach runtime service account identity and public ingress permissions.
Pass `--service-account=orders-identity@my-project.iam.gserviceaccount.com` and `--allow-unauthenticated` flags.
This establishes least-privilege service identity while exposing the service publicly.

Key Concept

Cloud Run Container Port Contract and Identity Deployment Flags
Estimated Time:2m 0s
Rate this question