Bird
Raised Fist0
GCPcloud~20 mins

Deploying container images in GCP - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Container Deployment Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate
2:00remaining
Understanding container image deployment behavior on Google Cloud Run

You deploy a container image to Google Cloud Run with the default settings. What happens when the container crashes repeatedly during startup?

ACloud Run sends an alert email to the project owner and pauses the service.
BCloud Run automatically retries starting the container several times before marking the service as unavailable.
CCloud Run scales up additional container instances to compensate for the crash.
DCloud Run immediately stops trying and marks the service as failed without retries.
Attempts:
2 left
💡 Hint

Think about how Cloud Run handles transient failures to keep services available.

❓ Configuration
intermediate
2:00remaining
Configuring environment variables for a container deployed on Google Kubernetes Engine (GKE)

You want to deploy a container on GKE and pass environment variables to it. Which YAML snippet correctly sets environment variables in the container spec?

GCP
apiVersion: v1
kind: Pod
metadata:
  name: env-test
spec:
  containers:
  - name: test-container
    image: gcr.io/my-project/my-image
    env:
      - name: VAR1
        value: "value1"
      - name: VAR2
        value: "value2"
A
env_vars:
  - VAR1=value1
  - VAR2=value2
B
environment:
  VAR1: value1
  VAR2: value2
C
env:
  - name: VAR1
    value: "value1"
  - name: VAR2
    value: "value2"
D
variables:
  - name: VAR1
    value: value1
  - name: VAR2
    value: value2
Attempts:
2 left
💡 Hint

Look for the correct Kubernetes container environment variable syntax.

❓ Architecture
advanced
2:00remaining
Designing a scalable container deployment on Google Cloud Run with traffic splitting

You want to deploy a new version of your container image on Cloud Run and gradually shift 30% of traffic to it while keeping 70% on the old version. Which approach achieves this?

ADeploy the new revision and use Cloud Run traffic splitting to route 30% to the new revision and 70% to the old revision.
BDeploy the new revision and update the service to point only to the new revision, then manually redirect 30% of users via DNS.
CDeploy the new revision and delete the old revision to force 30% traffic to the new one.
DDeploy the new revision and create a separate Cloud Run service for it, then use a load balancer to split traffic.
Attempts:
2 left
💡 Hint

Cloud Run supports traffic splitting natively between revisions.

❓ security
advanced
2:00remaining
Securing container image access in Google Container Registry (GCR)

You want to restrict access to your private container images in GCR so only a specific Cloud Run service can pull them. What is the best way to do this?

AGrant the Cloud Run service's service account the 'Storage Object Viewer' role on the GCR bucket.
BMake the GCR bucket public and rely on Cloud Run authentication to restrict access.
CUse a firewall rule to block all IPs except Cloud Run's IP range.
DEmbed the GCR credentials inside the container image for authentication.
Attempts:
2 left
💡 Hint

Think about IAM roles and permissions for accessing GCR images.

✅ Best Practice
expert
2:00remaining
Optimizing container image deployment speed and cost on Google Cloud Build and Cloud Run

You want to minimize deployment time and cost when building and deploying container images to Cloud Run. Which practice is most effective?

ADeploy directly from source code to Cloud Run without building a container image.
BBuild the entire container image from scratch every time to ensure freshness, then deploy.
CPush the container image to Docker Hub instead of Google Container Registry to reduce costs.
DUse Cloud Build caching to reuse layers and build only changed parts, then deploy the image to Cloud Run.
Attempts:
2 left
💡 Hint

Consider how build caching affects build speed and cost.

Practice

(1/5)
1. What is the main purpose of deploying a container image on Google Cloud Run?
easy
A. To run applications without managing servers
B. To create virtual machines manually
C. To store data in a database
D. To write code directly in the cloud console

Solution

  1. Step 1: Understand what Cloud Run does

    Cloud Run runs containerized apps without needing you to manage servers.
  2. Step 2: Compare options to Cloud Run's purpose

    Options B, C, and D describe other cloud tasks, not Cloud Run's main use.
  3. Final Answer:

    To run applications without managing servers -> Option A
  4. Quick Check:

    Cloud Run = serverless app running [OK]
Hint: Cloud Run runs apps without servers [OK]
Common Mistakes:
  • Confusing Cloud Run with VM creation
  • Thinking Cloud Run stores data
  • Assuming Cloud Run is a coding environment
2. Which command correctly deploys a container image to Cloud Run in the us-central1 region?
easy
A. gcloud deploy run myapp --image=gcr.io/myproject/myimage --zone=us-central1
B. gcloud run deploy myapp --image=gcr.io/myproject/myimage --region=us-central1
C. gcloud run create myapp --image=gcr.io/myproject/myimage --zone=us-central1
D. gcloud run deploy --image=myimage gcr.io/myproject --region=us-central1

Solution

  1. Step 1: Identify correct gcloud command syntax

    The correct command is 'gcloud run deploy' followed by service name, image, and region.
  2. Step 2: Check each option for syntax errors

    gcloud run deploy myapp --image=gcr.io/myproject/myimage --region=us-central1 matches correct syntax. Options B, C, and D have wrong commands or argument order.
  3. Final Answer:

    gcloud run deploy myapp --image=gcr.io/myproject/myimage --region=us-central1 -> Option B
  4. Quick Check:

    Correct deploy syntax = gcloud run deploy myapp --image=gcr.io/myproject/myimage --region=us-central1 [OK]
Hint: Use 'gcloud run deploy' with --image and --region [OK]
Common Mistakes:
  • Using 'gcloud deploy run' instead of 'gcloud run deploy'
  • Confusing --zone with --region
  • Incorrect argument order
3. Given this command:
gcloud run deploy myservice --image=gcr.io/myproj/app:v1 --region=us-east1
What happens after running it?
medium
A. The container image is deployed as a Cloud Run service named 'myservice' in us-east1 region
B. A virtual machine named 'myservice' is created in us-east1
C. The image is uploaded to Google Container Registry only
D. The command fails because region must be us-central1

Solution

  1. Step 1: Understand the deploy command effect

    The command deploys the container image as a Cloud Run service with the given name and region.
  2. Step 2: Evaluate other options

    B is wrong because no VM is created. C is wrong because deployment runs the image, not just upload. A is wrong because us-east1 is a valid region.
  3. Final Answer:

    The container image is deployed as a Cloud Run service named 'myservice' in us-east1 region -> Option A
  4. Quick Check:

    Deploy command = service deployment [OK]
Hint: Deploy runs container as service, not VM or just upload [OK]
Common Mistakes:
  • Thinking deploy creates VM
  • Confusing upload with deploy
  • Assuming region must be us-central1
4. You run:
gcloud run deploy --image=gcr.io/myproj/app:v2 --region=us-west1
But get an error: "Service name is required." What is the fix?
medium
A. Remove the --region flag
B. Change --image to --container-image
C. Add the service name after 'deploy', e.g., 'gcloud run deploy myservice ...'
D. Run the command without 'gcloud run'

Solution

  1. Step 1: Identify missing required argument

    The error says service name is missing; the deploy command needs a service name after 'deploy'.
  2. Step 2: Fix the command by adding service name

    Add the service name, e.g., 'myservice', after 'deploy' to fix the error.
  3. Final Answer:

    Add the service name after 'deploy', e.g., 'gcloud run deploy myservice ...' -> Option C
  4. Quick Check:

    Deploy needs service name [OK]
Hint: Always specify service name after 'deploy' [OK]
Common Mistakes:
  • Omitting service name
  • Changing unrelated flags
  • Removing required command parts
5. You want to deploy a new version of your app container image to Cloud Run and keep the same service URL. Which command should you use?
hard
A. gcloud container deploy myapp --image=gcr.io/myproj/app:v2
B. gcloud run create myapp --image=gcr.io/myproj/app:v2 --region=us-central1
C. gcloud run deploy --image=gcr.io/myproj/app:v2 --region=us-central1
D. gcloud run deploy myapp --image=gcr.io/myproj/app:v2 --region=us-central1

Solution

  1. Step 1: Understand updating a Cloud Run service

    To update an existing service and keep its URL, use 'gcloud run deploy' with the same service name.
  2. Step 2: Check options for correct update command

    gcloud run deploy myapp --image=gcr.io/myproj/app:v2 --region=us-central1 uses 'deploy' with service name and new image, which updates the service. Options A, B, and D are incorrect commands or missing service name.
  3. Final Answer:

    gcloud run deploy myapp --image=gcr.io/myproj/app:v2 --region=us-central1 -> Option D
  4. Quick Check:

    Deploy with same service name updates app [OK]
Hint: Use 'deploy' with same service name to update [OK]
Common Mistakes:
  • Using 'create' instead of 'deploy' to update
  • Omitting service name
  • Using wrong gcloud commands
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard