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
Which flag of gcloud run deploy builds and deploys directly from a local source directory?
- --source
- --image
- --build-dir
- --dockerfile
Show answer
Answer: A. --source
--source builds from a directory using a Dockerfile or buildpacks. --image expects an already built container image.
Which approaches work for configuring a Cloud Run service with settings and credentials?
- --set-env-vars LOG_LEVEL=info
- --set-secrets API_KEY=my-secret:latest
- --set-passwords API_KEY=value
- Hard-code the password in the container image
- 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: 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.
