An operations engineer is deploying a stateless backend microservice to Google Cloud Run using the gcloud command-line interface. The service must accept incoming asynchronous HTTP calls from an authenticated client application while adhering to Google Cloud security and container environment standards. Which of the following configuration steps are required to ensure successful deployment and invocation of this Cloud Run service? (Select TWO options.)
- Configure the containerized application to listen on the HTTP port specified by the PORT environment variable, which defaults to 8080.Answer
- BHardcode the application inside the container image to listen exclusively on port 3000 and omit the --port flag during gcloud run deploy.
- Grant the predefined Cloud Run Invoker role (roles/run.invoker) to the service account or identity making requests to the service.Answer
- DAssign the primitive Owner role (roles/owner) to the Cloud Run runtime service account to grant ingress access for incoming HTTP traffic.
Answer
To successfully deploy and enable authenticated access to a Cloud Run service, the application must listen on the port injected by the PORT environment variable (default 8080), and the calling principal must be granted the Cloud Run Invoker role (roles/run.invoker).
Cloud Run requires containers to listen for HTTP requests on the port specified by the PORT environment variable (default 8080). Additionally, private Cloud Run services require callers to hold the predefined Cloud Run Invoker role (roles/run.invoker) to authenticate requests.
Step-by-Step Solution
Key Concept
Cloud Run Container Port Contract and IAM Invoker Permissions