Bitzu

Associate Cloud Engineer ยท Containers and serverless deployments

Deploying to Cloud Run

gcloud run deploy from an image or source, services vs jobs, Cloud Run functions deploy, authentication (allow unauthenticated vs invoker role), environment variables and secrets.

Key points

  • gcloud run deploy SERVICE with --image (existing container) or --source (build from code, using a Dockerfile or buildpacks).
  • Services serve requests; jobs (gcloud run jobs deploy) run tasks to completion.
  • Access: --allow-unauthenticated for public, otherwise callers need the Cloud Run Invoker role.
  • Config: --set-env-vars and --set-secrets (Secret Manager).

Source: https://docs.cloud.google.com/sdk/gcloud/reference/run/deploy

Practice questions

Single choice

Which flag of gcloud run deploy builds and deploys directly from a local source directory?

  1. --source
  2. --image
  3. --build-dir
  4. --dockerfile
Show answer

Answer: A. --source

--source builds from a directory using a Dockerfile or buildpacks. --image expects an already built container image.

Select all that apply

Which approaches work for configuring a Cloud Run service with settings and credentials?

  1. --set-env-vars LOG_LEVEL=info
  2. --set-secrets API_KEY=my-secret:latest
  3. --set-passwords API_KEY=value
  4. Hard-code the password in the container image
  5. Store the key in a public Cloud Storage bucket
Show answer

Answer: A. --set-env-vars LOG_LEVEL=info, B. --set-secrets API_KEY=my-secret:latest

--set-env-vars sets plain variables and --set-secrets mounts Secret Manager secrets. Baking a password into the image or a public bucket is insecure and not a configuration flag.

True or false

True or false: a Cloud Run service deployed without --allow-unauthenticated can be called by any anonymous internet user.

Show answer

Answer: False

False. Without public access, callers must present an identity that holds the Cloud Run Invoker role.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More Associate Cloud Engineer topics in this module