Compute Engine & GKE

💤0
Lv 10 XP
← 🌐 Google Cloud · Core Services

Compute Engine & GKE

Intermediate ⭐ 80 XP ⏱ 18 min #gcp#compute#gke

Choose between VMs, managed Kubernetes, and serverless on Google Cloud.

📖Theory

GCP offers a spectrum of compute, from most to least control:

  • Compute Engine — VMs (IaaS); supports preemptible/Spot VMs and managed instance groups for autoscaling
  • GKE — managed Kubernetes; Autopilot mode runs pods without you managing nodes
  • Cloud Run — serverless containers, scale to zero, pay per request
  • Cloud Functions — event-driven functions
  • App Engine — managed app platform (PaaS)

The decision: full OS control → Compute Engine; container orchestration → GKE; stateless containers without cluster ops → Cloud Run.

🌍Real-World Example
# A VM
gcloud compute instances create web1 \
  --zone=europe-west1-b --machine-type=e2-small --image-family=debian-12 \
  --image-project=debian-cloud

# A serverless container on Cloud Run
gcloud run deploy myapp --image=gcr.io/my-project/myapp --region=europe-west1
✍️Hands-On Exercise
  1. Map three workloads to Compute Engine, GKE, and Cloud Run.
  2. Explain what a managed instance group adds over a single VM.
  3. Describe when Cloud Run is preferable to GKE.
  4. What is a preemptible/Spot VM and when would you use one?
🧾Cheat Sheet
ServiceUse
Compute EngineVMs, full control (IaaS)
Managed instance groupAutoscaling VMs
GKE (Autopilot)Managed Kubernetes
Cloud RunServerless containers, scale to zero
Cloud FunctionsEvent-driven functions
App EngineManaged app platform
💬Common Interview Questions
When would you choose Cloud Run over GKE?

When you have stateless containers and want serverless scaling (including to zero) without managing a Kubernetes cluster. GKE fits when you need full orchestration control, complex networking, or stateful workloads.

What is a managed instance group?

A group of identical Compute Engine VMs that supports autoscaling, autohealing, and rolling updates behind a load balancer — GCP’s equivalent of an autoscaling group.

📚Official Documentation

📝 My notes on this topic

Auto-saves as you type