GCP · Serverless
Cloud Run
Containers, serverless, request-priced.
Official docsOverview
Cloud Run runs stateless containers, auto-scaling to zero, billing per request and CPU time. Great for APIs and ephemeral QA environments.
When to use it
- Per-PR ephemeral preview environments
- API mocks/stubs for contract testing
- Internal QA dashboards
Setup
- Build and push image: `gcloud builds submit --tag gcr.io/PROJECT/svc`.
- Deploy: `gcloud run deploy svc --image gcr.io/PROJECT/svc --region us-central1`.
- Set IAM (allow unauth or restrict to invokers).
How to use
Deploy revision
gcloud run deploy api --image gcr.io/PROJECT/api --region us-central1 --allow-unauthenticatedTraffic split (canary)
gcloud run services update-traffic api --to-revisions=api-002=10,api-001=90QA use cases
- Spin a Cloud Run service per pull request for end-to-end tests, tear down after merge.
- Canary deploys gated by smoke tests against the 10% revision.
