Soru

Zorluk: OrtaDeploying Serverless Applications with Cloud Run and Cloud Functions

A cloud engineer needs to deploy a containerized web application to Google Cloud Run from local application source code in a newly created Google Cloud project. Place the operational steps in the correct execution sequence from first to last.

  1. 1Enable the Cloud Run API and Cloud Build API in the target project.
  2. 2Package the local source code into a container image and push it to Artifact Registry using `gcloud builds submit`.
  3. 3Deploy the container image to Cloud Run using `gcloud run deploy` specifying the image artifact location.
  4. 4Grant the `roles/run.invoker` IAM role to authorized callers using `gcloud run services add-iam-policy-binding`.

Cevap

The correct execution sequence is: 1. Enable the Cloud Run API and Cloud Build API. 2. Package and push the container image to Artifact Registry using gcloud builds submit. 3. Deploy the container image to Cloud Run using gcloud run deploy. 4. Grant the roles/run.invoker IAM role using gcloud run services add-iam-policy-binding.
The correct order follows the lifecycle dependencies of serverless container deployments on GCP. First, API enablement enables project capabilities. Second, Cloud Build compiles local code into a stored container artifact in Artifact Registry. Third, Cloud Run references that artifact to create a revision and endpoint. Fourth, IAM policy binding sets invoker access permissions on the created Cloud Run service.

Adım Adım Çözüm

1
Enable required Google Cloud Service APIs
Cloud Run and Cloud Build APIs are active in the project
Google Cloud service endpoints must be enabled prior to invoking build and deployment commands.
2
Execute `gcloud builds submit --tag LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE:TAG`
Container image is compiled and pushed to Artifact Registry
Cloud Run requires an existing container image hosted in Artifact Registry or Container Registry.
3
Execute `gcloud run deploy SERVICE_NAME --image LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE:TAG`
Cloud Run revision is created and assigned an HTTPS endpoint
Deploys the packaged container workload to the managed serverless infrastructure.
4
Execute `gcloud run services add-iam-policy-binding SERVICE_NAME --member=... --role=roles/run.invoker`
IAM invoker permissions are assigned to the deployed service
Secures or exposes the active service endpoint to specified identities.

Anahtar Kavram

Cloud Run deployment workflow from source code using gcloud CLI and Artifact Registry
Bu soruyu puanla