Soru

Zorluk: OrtaDeploying Serverless Applications with Cloud Run and Cloud Functions

A DevOps engineer is deploying a newly containerized Flask web application named `inventory-api` to Google Cloud Run using the `gcloud run deploy` command. The application is configured to listen internally on TCP port 5000 rather than the standard default port. The application needs to be accessible directly from the public internet without requiring IAM authentication header tokens. Which two configuration actions or `gcloud` command flags must be used to successfully deploy this service? (Select TWO.)

  1. Include the `--port=5000` flag during deployment to direct Cloud Run routing to the application's listening port.Cevap
  2. Include the `--allow-unauthenticated` flag during deployment to enable public HTTP access.Cevap
  3. C
    Hardcode `ENV PORT=8080` in the Dockerfile while leaving the Flask application bound to port 5000.
  4. D
    Grant the primitive `roles/owner` role to the default Cloud Run service account to permit unauthenticated inbound HTTP requests.

Cevap

To successfully deploy the containerized web application to Cloud Run with public access and custom port routing, you must use the `--port=5000` flag to inform Cloud Run which port the container receives requests on, and use the `--allow-unauthenticated` flag to allow public ingress without authentication.
Deploying containerized applications to Cloud Run requires configuring container ingress port contract and access control. Specifying the flag `--port=5000` ensures Cloud Run routes incoming container requests to port 5000 where Flask is listening. Specifying `--allow-unauthenticated` allows public HTTP clients to invoke the Cloud Run URL without providing GCP authentication credentials.

Adım Adım Çözüm

1
Identify container port routing requirements.
Cloud Run injects the `PORT` environment variable (default 8080). If the application listens on port 5000, passing `--port=5000` sets `PORT=5000` and configures ingress traffic to target port 5000.
If Cloud Run attempts to send requests to 8080 while the process listens on 5000, startup probes will fail.
2
Identify public access invocation requirements.
Adding `--allow-unauthenticated` configures IAM policy bindings on the deployed service to allow `allUsers` invocation.
By default, new Cloud Run services require IAM authentication headers unless unauthenticated invocations are explicitly allowed.

Anahtar Kavram

Cloud Run Container Port Binding and Ingress Access Control
Tahmini Süre:1m 30s
Bu soruyu puanla