Question

Difficulty: HardDeploying Serverless Applications with Cloud Run and Cloud Functions

A software engineering team is deploying a custom containerized internal service named billing-service to Google Cloud Run in the us-central1 region. The application container is hardcoded to listen for incoming gRPC traffic on TCP port 5000 rather than the default port 8080. The service must execute under a specific non-default service account named [email protected] and must block unauthenticated public invocations. Which gcloud command correctly deploys this service according to the security and operational requirements?

  1. gcloud run deploy billing-service --image=gcr.io/my-project/billing-service:v1 --port=5000 [email protected] --no-allow-unauthenticatedAnswer
  2. B
    gcloud run deploy billing-service --image=gcr.io/my-project/billing-service:v1 --set-env-vars=CUSTOM_PORT=5000 [email protected] --no-allow-unauthenticated
  3. C
    gcloud functions deploy billing-service --image=gcr.io/my-project/billing-service:v1 --port=5000 [email protected] --no-allow-unauthenticated
  4. D
    gcloud run deploy billing-service --image=gcr.io/my-project/billing-service:v1 --port=5000 --role=roles/editor --no-allow-unauthenticated

Answer

The correct deployment command is gcloud run deploy billing-service --image=gcr.io/my-project/billing-service:v1 --port=5000 [email protected] --no-allow-unauthenticated.
The correct command uses gcloud run deploy with --port=5000 to direct incoming traffic to the container's listening port, --service-account to bind the dedicated IAM identity, and --no-allow-unauthenticated to restrict unauthenticated access.

Step-by-Step Solution

1
Identify container port requirements for Cloud Run
By default, Cloud Run routes HTTP requests to port 8080. If a container listens on port 5000, the --port=5000 flag must be passed to gcloud run deploy.
Ensures the Cloud Run proxy forwards ingress requests to the container's active listening port.
2
Identify service account configuration flag
To override the default Compute Engine service account, use --service-account followed by the full service account email address.
Adheres to the principle of least privilege by running the workload under a dedicated IAM identity.
3
Configure authentication requirements
Pass --no-allow-unauthenticated to ensure IAM authentication is enforced for all ingress requests.
Prevents unauthorized public access to the deployed microservice.

Key Concept

Deploying containerized workloads on Cloud Run with non-default port bindings, custom service accounts, and IAM ingress controls.
Rate this question