Question

Difficulty: MediumDeploying Serverless Applications with Cloud Run and Cloud Functions

A DevOps engineer needs to package a Python web application from local source code into a container image and deploy it to Google Cloud Run using the gcloud CLI. Place the following operational steps in the correct sequential order from first to last.

  1. 1Submit the local source code and Dockerfile to Cloud Build using gcloud builds submit to compile and push the container image to Artifact Registry.
  2. 2Deploy the container image to Cloud Run using gcloud run deploy, specifying the container image location, target region, and enabling unauthenticated access.
  3. 3Update the Cloud Run service configuration using gcloud run services update to set application environment variables.
  4. 4Execute an HTTP GET request using curl against the generated Cloud Run service URL to confirm successful deployment and response.

Answer

The correct sequence of steps is: 1) Build and push the container image to Artifact Registry using gcloud builds submit, 2) Deploy the container image to Cloud Run using gcloud run deploy, 3) Update service environment variables using gcloud run services update, and 4) Verify live service response by making an HTTP request to the assigned service URL.
Deploying a containerized web application to Cloud Run follows a logical lifecycle: first, source code must be built into a container image and pushed to Artifact Registry using Cloud Build. Second, the container image is deployed to Cloud Run using gcloud run deploy to provision the service revision. Third, service-level configurations such as environment variables are updated using gcloud run services update. Finally, sending an HTTP request to the live Cloud Run endpoint verifies that the deployment is functional and accepting requests.

Step-by-Step Solution

1
Build and push container artifact
The application code is compiled into a container image stored in Artifact Registry.
Cloud Run requires an accessible container image artifact in a registry before deploying a service.
2
Deploy container to Cloud Run
A Cloud Run service and initial revision are provisioned with an assigned HTTPS endpoint.
Executing gcloud run deploy provisions serverless infrastructure hosting the specified container image.
3
Update service runtime configuration
The Cloud Run service specification is updated with environment variables.
Post-deployment configuration changes modify the service configuration to supply required application variables.
4
Verify service health
The service returns an HTTP 200 OK status from the HTTPS URL.
Issuing an HTTP GET request verifies that the container starts up and handles requests properly.

Key Concept

Deploying serverless containerized applications to Cloud Run using gcloud CLI build and deployment workflows
Rate this question