Cloud Run
Exam guide§2.1
Run code without managing servers. Everything scales automatically and can scale to zero.
- Deploy a container (from Artifact Registry) or deploy from source (
--source, buildpacks). Must listen on$PORT, be stateless, respond to HTTP/gRPC/events. - Two resource types: services (request-based, HTTP/gRPC) and jobs (run-to-completion tasks).
- Built on Knative (open API + runtime on Kubernetes), so the same container runs fully managed on Google Cloud, on GKE, or anywhere Knative runs - avoids lock-in.
Features & benefits
Services and jobs
Cloud Run runs a container two ways:
- A service handles requests. It gives you a reliable HTTPS endpoint and autoscales; your only job is to listen on
$PORTand handle HTTP/gRPC. Detail: Resource model. - A job runs code that does work and then quits - a script, batch task, or migration. It starts one container instance, or (an Array job) many identical instances in parallel to finish faster - e.g. process many Cloud Storage files at once, one per instance. Run it from
gcloud, schedule it, or drive it from a workflow.
What's in this section
Read top to bottom for a first pass; each page also stands alone as revision notes.
| Page | What you'll learn |
|---|---|
| Resource model | Service, revision, container instance, job, task - the nouns and how they nest |
| Develop, test & deploy | App fit, source-to-container, the runtime contract, execution environments, local testing |
| Container lifecycle | The five runtime states: starting, serving, idle, shutting down, stopped |
| Autoscaling & concurrency | Scale to zero, min/max instances, concurrency, cold starts |
| Revisions & traffic | Immutable revisions; split, pin, and tag traffic for canary and rollback |
| Secrets & env vars | Inject config and Secret Manager values into a container |
| Access & networking | Inbound IAM (who can invoke), ingress, and reaching a VPC network |
| Service identity | The identity your code runs as when it calls other Google Cloud APIs |
| Integrating with services | Client libraries, Memorystore, Cloud SQL, and managed integrations |
| Invocation & event triggers | How a service is invoked: HTTP/gRPC, Pub/Sub push, Eventarc, Cloud Scheduler, Cloud Tasks |
| Cloud Run functions | Deploy a single function; the Functions Framework and Cloud Storage triggers |
Recap
Single small event handler→Cloud Run functions
Full app, custom container, any binary→Cloud Run
Web/API service, gRPC→Cloud Run
Route many GCP event sources to a service→Eventarc + Cloud Run