Soru

Zorluk: Çok zorDeploying Serverless Applications with Cloud Run and Cloud Functions

Your organization is establishing a deployment pipeline for a stateless containerized web application using Google Cloud Run in the us-central1 region. The application source code is stored locally and needs to be built into a container image, stored in a managed repository, and deployed to Cloud Run with public unauthenticated access enabled. What is the correct sequence of execution steps to deploy this serverless application using the Google Cloud CLI from start to finish?

  1. 1Enable the Cloud Run API (`run.googleapis.com`) and Artifact Registry API (`artifactregistry.googleapis.com`) in your Google Cloud project using `gcloud services enable`.
  2. 2Create a Docker repository in Artifact Registry in the `us-central1` region using `gcloud artifacts repositories create`.
  3. 3Submit the local source code to Cloud Build to compile and push the container image to Artifact Registry using `gcloud builds submit --tag us-central1-docker.pkg.dev/PROJECT_ID/my-repo/my-app:v1`.
  4. 4Deploy the container image to Cloud Run and configure public access using `gcloud run deploy my-service --image us-central1-docker.pkg.dev/PROJECT_ID/my-repo/my-app:v1 --region us-central1 --allow-unauthenticated`.

Cevap

The correct sequence of steps begins with enabling the Cloud Run and Artifact Registry APIs, followed by creating the Artifact Registry Docker repository, then submitting the source code to Cloud Build to build and push the container image, and finally deploying the container image from Artifact Registry to Cloud Run using gcloud run deploy with the --allow-unauthenticated flag.
The deployment of a serverless Cloud Run application follows a strict dependency order: API enablement allows resource management, creating the Artifact Registry repository provides the storage destination, compiling source code via Cloud Build pushes the container image to that repository, and finally running gcloud run deploy references the stored image to deploy the running service.

Adım Adım Çözüm

1
Enable required Cloud APIs
Cloud Run and Artifact Registry APIs are active and ready to accept API requests.
Google Cloud service APIs must be enabled prior to creating resources or invoking deployment tools that rely on those APIs.
2
Create Artifact Registry Repository
A regional Docker repository is available in us-central1 to store built container images.
Artifact Registry requires an existing target repository of type Docker before images can be stored.
3
Build and Store Container Image
Cloud Build compiles the source code into a container image and tags/pushes it to Artifact Registry.
Cloud Run requires an accessible container image stored in Artifact Registry (or Container Registry) to instantiate service instances.
4
Deploy Service to Cloud Run
The Cloud Run service is deployed, receives a HTTPS endpoint URL, and permits unauthenticated access.
The gcloud run deploy command provisions the service using the fully qualified Artifact Registry image path.

Anahtar Kavram

Serverless Container Deployment Workflow with Cloud Run and Artifact Registry
Bu soruyu puanla