Soru

Zorluk: OrtaDeploying Serverless Applications with Cloud Run and Cloud Functions

A cloud developer is deploying a containerized REST API microservice named orders-api to Google Cloud Run using the gcloud command-line tool. The microservice needs to accept public HTTP traffic from external clients and dynamically receive requests on the port assigned by the platform container contract. Which two configuration actions are required to ensure the microservice successfully receives and handles incoming requests on Cloud Run? Select 2 options.

  1. Configure the application container code to listen on the HTTP port defined by the PORT environment variable injected by Cloud Run.Cevap
  2. Include the --allow-unauthenticated flag when executing the gcloud run deploy command.Cevap
  3. C
    Hardcode port 80 in the Dockerfile EXPOSE directive and override the PORT environment variable to 80, as Cloud Run routes traffic exclusively through port 80 inside the container.
  4. D
    Grant the primitive roles/Editor role to the default compute service account at the project level to enable public HTTP invocation.

Cevap

The microservice requires configuring the container application to listen on the port specified by the injected PORT environment variable and deploying the service with the --allow-unauthenticated flag to accept public HTTP traffic.
Cloud Run requires containers to comply with its runtime contract by listening on the port provided in the PORT environment variable. Additionally, to expose a service to public unauthenticated callers, the deployment command must pass the --allow-unauthenticated flag.

Adım Adım Çözüm

1
Verify container runtime contract adherence
The application code must listen on the port assigned via the PORT environment variable.
Cloud Run sends requests to the container on the PORT environment variable value, which defaults to 8080.
2
Set invocation permissions during deployment
Use gcloud run deploy orders-api with the --allow-unauthenticated flag.
Public HTTP access requires explicitly permitting unauthenticated invocations on the service endpoint.

Anahtar Kavram

Cloud Run Container Contract and Ingress Authentication
Bu soruyu puanla