1. Compute Engine #
VMs.
VMs and managed groups #
gcloud compute instances create web-1 --zone=europe-west9-a --machine-type=e2-medium \
--image-family=debian-12 --image-project=debian-cloud --no-address --service-account=web@mon-projet.iam.gserviceaccount.com --scopes=cloud-platform
gcloud compute instance-templates create web-tpl --machine-type=e2-medium --image-family=debian-12 --image-project=debian-cloud --metadata-from-file=startup-script=installer.sh
gcloud compute instance-groups managed create web-mig --template=web-tpl --size=2 --region=europe-west9
gcloud compute instance-groups managed set-autoscaling web-mig --region=europe-west9 --max-num-replicas=10 --target-cpu-utilization=0.62. Cloud Run #
Serverless containers.
Principles #
Cloud Run runs an HTTP container (or a job) scaled automatically, down to zero instances, billed per use. Immutable revisions, traffic splitting between revisions (canary), identity through a service account.
gcloud run deploy api --source . --region=europe-west9 --allow-unauthenticated
gcloud run services update-traffic api --region=europe-west9 --to-revisions=api-00002-abc=10,api-00001-xyz=90
gcloud run services logs read api --region=europe-west9 --limit=203. GKE and functions #
Kubernetes and events.
Choosing #
| Service | Usage |
|---|---|
| GKE Autopilot | Kubernetes where Google manages the nodes; billing per pod |
| GKE Standard | Full control over node pools |
| Cloud Run functions | Functions triggered by HTTP, Pub/Sub, Cloud Storage, Eventarc |
| App Engine | Historical web application platform |
Good practice: The official emulators (Pub/Sub, Firestore) and the Functions Framework let you develop these services locally: see the hands-on labs.
