0
0
GCPcloud~10 mins

Cloud Run for containerized services in GCP - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Cloud Run for containerized services
Write containerized app
Build container image
Push image to Container Registry
Deploy image to Cloud Run
Cloud Run creates service
Service listens for requests
Requests routed to container instances
Scale instances up/down automatically
Billing based on usage
This flow shows how you build a container, push it, deploy to Cloud Run, and how Cloud Run manages requests and scaling automatically.
Execution Sample
GCP
gcloud builds submit --tag gcr.io/my-project/my-app

gcloud run deploy my-service --image gcr.io/my-project/my-app --platform managed

# Service is live and scales automatically
This code builds a container image from your app and deploys it to Cloud Run, which then runs and scales your service.
Process Table
StepActionInput/ConditionResult/Output
1Build container imageSource code + DockerfileContainer image created
2Push imageContainer imageImage uploaded to Container Registry
3Deploy to Cloud RunImage URLCloud Run service created
4Service startsNo requests yetNo container instances running
5First request arrivesHTTP requestCloud Run starts container instance
6Handle requestContainer instance runningResponse sent to client
7More requestsIncreased trafficCloud Run scales instances up
8Traffic dropsNo requestsCloud Run scales instances down to zero
9BillingBased on CPU, memory, and request timeCharges applied only when serving requests
💡 Execution stops when no requests remain and Cloud Run scales down to zero instances.
Status Tracker
VariableStartAfter Step 4After Step 5After Step 7Final
Container Instances00130
Traffic Load001 requestHigh requests0
Billing Meter00Starts countingIncreasesStops counting
Key Moments - 3 Insights
Why are there zero container instances before the first request?
Cloud Run scales to zero when idle to save resources, as shown in execution_table step 4.
How does Cloud Run know when to start more container instances?
It monitors incoming requests and scales up automatically, as seen in steps 5 and 7.
When does billing start and stop?
Billing starts when container instances handle requests (step 5) and stops when scaled down to zero (step 8).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, how many container instances are running after step 7?
A0
B1
C3
D5
💡 Hint
Check the 'Container Instances' variable in variable_tracker after Step 7.
At which step does Cloud Run start the first container instance?
AStep 5
BStep 3
CStep 4
DStep 6
💡 Hint
Look at execution_table where the first request triggers container start.
If no requests come in, what happens to container instances according to the tables?
AThey stay running
BThey scale down to zero
CThey increase
DThey restart continuously
💡 Hint
See execution_table step 8 and variable_tracker final state.
Concept Snapshot
Cloud Run runs container images as services.
It automatically scales from zero to many instances.
You pay only when your service handles requests.
Deploy by pushing container image and running 'gcloud run deploy'.
Cloud Run manages infrastructure and scaling for you.
Full Transcript
Cloud Run lets you run containerized apps without managing servers. First, you build your app into a container image. Then you push this image to a container registry. Next, you deploy the image to Cloud Run, which creates a service. Initially, no container instances run until a request arrives. When a request comes, Cloud Run starts a container instance to handle it. If traffic grows, Cloud Run automatically adds more instances. When traffic stops, it scales down to zero to save resources. Billing is based on the time your containers run and handle requests. This makes Cloud Run efficient and cost-effective for running containerized services.