Google Kubernetes Engine (GKE)

Google Cloud · Advanced · 16 min

GKE is the platform for many-service systems that need Kubernetes' scheduling, ecosystem and portability.

GKE runs the Kubernetes control plane for you. Two modes:

  • Autopilot: Google also manages nodes. You deploy Pods; you pay for the CPU, memory and storage your Pods request. Security hardening and Workload Identity are on by default. The recommended default.
  • Standard: you manage node pools (machine types, autoscaling, Spot nodes, GPUs) and pay for the nodes, used or not. Needed for privileged workloads or very custom node setups.

Clusters are regional (control plane and nodes across three zones) or zonal; use regional for production. Enrol in a release channel (Rapid, Regular, Stable, Extended) so control plane and nodes are upgraded automatically, and use maintenance windows and exclusions to control when.

Networking is VPC-native: Pods and Services get IPs from subnet secondary ranges, so Pods are directly routable in the VPC. A Service of type LoadBalancer creates a passthrough Network Load Balancer; a Gateway or Ingress creates an Application Load Balancer that can send traffic straight to Pods via NEGs.

Access uses gcloud container clusters get-credentials, which writes a kubeconfig that authenticates through the gke-gcloud-auth-plugin. Cluster access is controlled by both IAM (e.g. roles/container.developer) and Kubernetes RBAC.

Compare with Cloud Run before choosing: GKE gives control and ecosystem at the price of operating Kubernetes.

Example

gcloud container clusters create-auto shop-gke --region=europe-west1 \
  --network=shop-vpc --subnetwork=shop-euw1 --release-channel=regular
gcloud container clusters get-credentials shop-gke --region=europe-west1

kubectl create deployment orders \
  --image=europe-west1-docker.pkg.dev/shop-dev-4821/apps/orders-api:1.4.0
kubectl set resources deployment orders --requests=cpu=250m,memory=512Mi
kubectl expose deployment orders --type=LoadBalancer --port=80 --target-port=8080
kubectl get service orders
# NAME     TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)
# orders   LoadBalancer   34.118.x.x     35.205.x.x     80:31234/TCP

Remember

  • Autopilot: pay per Pod request, nodes managed; Standard: you manage node pools
  • Regional clusters plus a release channel for production
  • VPC-native: Pods get routable VPC IPs from secondary ranges

Watch out for

  • Omitting resource requests on Autopilot and getting small defaults that throttle the app.

Check yourself

  1. In Autopilot, what mainly drives the compute bill?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: cloud.google.com/kubernetes-engine/docs/concepts/autopilot-overview