Soru

Zorluk: KolayDeploying Serverless Applications with Cloud Run and Cloud Functions

A backend team has built a stateless container image for a web microservice and pushed it to Artifact Registry at `us-docker.pkg.dev/my-project/apps/inventory-api:v1`. They want to quickly deploy this containerized application to Google Cloud Run and ensure it accepts public HTTP requests without requiring user authentication. Which `gcloud` command should they execute?

  1. gcloud run deploy inventory-api --image=us-docker.pkg.dev/my-project/apps/inventory-api:v1 --allow-unauthenticatedCevap
  2. B
    gcloud functions deploy inventory-api --image=us-docker.pkg.dev/my-project/apps/inventory-api:v1 --allow-unauthenticated
  3. C
    gcloud run deploy inventory-api --image=us-docker.pkg.dev/my-project/apps/inventory-api:v1 --port=8080 --no-allow-unauthenticated
  4. D
    gcloud run services update inventory-api --image=us-docker.pkg.dev/my-project/apps/inventory-api:v1 --to-latest

Cevap

Execute `gcloud run deploy inventory-api --image=us-docker.pkg.dev/my-project/apps/inventory-api:v1 --allow-unauthenticated`.
To deploy a container image to Cloud Run and allow public access, run `gcloud run deploy` specifying the image location with `--image` and setting the `--allow-unauthenticated` flag.

Adım Adım Çözüm

1
Identify the target deployment platform for container images
Cloud Run is designed to run arbitrary stateless container images stored in Container Registry or Artifact Registry.
Cloud Run consumes container images directly, whereas Cloud Functions primary workflow deploys code snippets.
2
Determine the gcloud command for initial service deployment
Use `gcloud run deploy <service-name>` along with the `--image` flag pointing to the Artifact Registry URI.
This command creates a new service and initial revision in Cloud Run.
3
Apply access control flag for public HTTP access
Pass the `--allow-unauthenticated` flag during deployment.
This flag grants the `roles/run.invoker` permission to `allUsers`, allowing unauthenticated public invocations.

Anahtar Kavram

Deploying Serverless Applications with Cloud Run
Bu soruyu puanla