Deploying a Service

Deploy from Source or Image

Example

From source code (Cloud Build builds the image for you), or from an image you already pushed:

# from source
gcloud run deploy course-api --source . --region asia-south1 --allow-unauthenticated

# from an image in Artifact Registry
gcloud run deploy course-api \
  --image asia-south1-docker.pkg.dev/shop-dev-1234/apps/course-api:1.2.0 \
  --region asia-south1

Example output

Deploying container to Cloud Run service [course-api] in project [shop-dev-1234] region [asia-south1]
✓ Deploying new service... Done.
  ✓ Creating Revision...
  ✓ Routing traffic...
Service URL: https://course-api-7xk2abcdea-el.a.run.app

Traffic Splitting

# deploy a new revision without sending it traffic
gcloud run deploy course-api --image ...:1.3.0 --no-traffic --tag canary

# send 10% of traffic to it, then 100% when it looks good
gcloud run services update-traffic course-api --to-tags canary=10
gcloud run services update-traffic course-api --to-latest

Tip: Rolling back is instant: route traffic to the previous revision.