TL;DR
Master container orchestration with Google Kubernetes Engine. Learn about cluster management, workload deployment, scaling, monitoring, and best practices for running containerized applications at scale.
Google Kubernetes Engine (GKE) - From Basics to Advanced
Executive Summary
GKE is Google's managed Kubernetes: Google runs the control plane, and you choose how much of the node layer you want to manage yourself — Standard clusters, where you configure node pools, or Autopilot, where Google manages nodes and you pay per pod. This guide covers the decisions that shape a production cluster: Standard versus Autopilot, regional versus zonal topology, node pool and autoscaling design, how workloads are exposed through Services and Ingress, and the security baseline (Workload Identity, network policies, hardened pod specs). After reading it, you should be able to create a cluster deliberately, deploy a workload with sane resource settings, and know which operational tasks remain yours.
Why This Matters
Kubernetes fails operationally more often than architecturally. Clusters created with defaults accumulate unpatched nodes, workloads without resource requests defeat the scheduler and the autoscaler, and a single zonal cluster turns a zone outage into an application outage. GKE removes the hardest part — running etcd and the control plane — but leaves you the parts that determine cost and reliability: node sizing, upgrade cadence, resource discipline, and network policy. Teams that treat cluster creation as a design exercise get a platform; teams that treat it as a wizard get a snowflake they are afraid to upgrade, and unpatched Kubernetes becomes a security liability on a deadline.
Core Concepts
Standard Versus Autopilot
| Feature | Standard cluster | Autopilot |
|---|---|---|
| Node management | Manual | Automated |
| Pricing | Per node | Per pod |
| Control | Full control | Limited control |
| Use case | Custom workloads | Simple deployments |
| Scaling | Manual/auto | Fully automated |
Autopilot is the better default for most workloads: Google provisions and patches nodes, enforces resource requests within sane bounds, and bills for pod requests rather than whole machines, which removes the classic bin-packing waste. Choose Standard when you need specific machine types, GPUs, local SSDs, custom node configuration, or privileged system daemons that Autopilot's guardrails prohibit.
Creating a Cluster
# Create standard cluster gcloud container clusters create my-cluster \ --zone us-central1-a \ --num-nodes 3 \ --machine-type e2-standard-4 # Create autopilot cluster gcloud container clusters create-auto my-autopilot \ --region us-central1
Prefer regional clusters for production: the control plane and, with regional node pools, your workloads survive a zonal failure. Choose a release channel (rapid, regular, stable) rather than pinning a static version — channels are how GKE keeps you patched without surprise jumps, and a cluster that falls behind supported versions becomes a forced, risky upgrade.
Deploying a Workload
A Deployment is the unit of everyday work. The fields that matter most operationally are the resource requests and limits, because the scheduler, autoscaler, and Autopilot's pricing all key off them:
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: gcr.io/PROJECT_ID/my-app:v1
ports:
- containerPort: 8080
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "200m"
memory: "256Mi"Set requests from measured usage, not hope. Over-requesting wastes money and blocks scheduling; under-requesting causes CPU throttling and OOM kills under load. Rollouts are controlled through the update strategy:
# rolling-update.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
template:
# ... pod template specStateful workloads use StatefulSets for stable identity and per-pod storage:
# statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: "nginx"
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1GiBefore reaching for a StatefulSet, check whether the state belongs in a managed database instead — it usually does.
Node Pools and Scaling (Standard)
Node pools group nodes with a shared configuration inside a Standard cluster, so GPU, high-memory, and general workloads can coexist:
# Create new node pool gcloud container node-pools create pool-2 \ --cluster my-cluster \ --zone us-central1-a \ --num-nodes 2 \ --machine-type n1-standard-4 # Enable autoscaling gcloud container clusters update my-cluster \ --enable-autoscaling \ --min-nodes 1 \ --max-nodes 5 \ --zone us-central1-a
Two autoscalers cooperate: the Horizontal Pod Autoscaler scales replicas from metrics, and the cluster autoscaler adds or removes nodes so pending pods can schedule. HPA is only as good as the requests it divides by:
# hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: my-app-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-app
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50Namespace-level ResourceQuotas keep one team from consuming the cluster, and PodDisruptionBudgets keep voluntary disruptions (drains, upgrades) from taking every replica down at once.
Exposing Workloads
A Service of type LoadBalancer gives a workload a cloud load balancer; an Ingress (backed by the GKE Ingress controller and Google Cloud Load Balancing) is the better tool for HTTP routing across services, TLS termination, and integration with Cloud Armor and Cloud CDN:
# load-balancer.yaml
apiVersion: v1
kind: Service
metadata:
name: my-app
annotations:
cloud.google.com/neg: '{"ingress": true}'
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
selector:
app: my-app# ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
annotations:
kubernetes.io/ingress.class: "gce"
spec:
rules:
- host: my-app.example.com
http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: my-app
port:
number: 80Security Baseline
Three controls do most of the work. Workload Identity lets pods authenticate as Google service accounts without downloaded keys — treat it as non-optional. Pod security settings keep containers from running as root or escalating privilege:
# pod-security.yaml
apiVersion: v1
kind: Pod
metadata:
name: secure-pod
spec:
securityContext:
runAsUser: 1000
runAsGroup: 3000
fsGroup: 2000
containers:
- name: secure-container
image: nginx
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: trueAnd network policies turn the cluster's flat network into segmented one — but only once the cluster and workloads are configured to enforce them:
# network-policy.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: api-allow
spec:
podSelector:
matchLabels:
app: api
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
role: frontend
ports:
- protocol: TCP
port: 8080Add Binary Authorization if you need a guarantee that only images built by your pipeline can run, and keep system and user workloads in separate node pools in Standard clusters so platform daemons and tenant pods do not contend.
Decision Framework
| Situation | Recommendation |
|---|---|
| Typical microservices, small platform team | Autopilot, regional cluster, release channel enabled |
| GPUs, custom kernels, or special node configuration | Standard cluster with dedicated node pools |
| Strong multi-tenancy between teams | Separate namespaces with quotas and network policies, or separate clusters for hard isolation |
| Bursty workloads | HPA plus cluster autoscaling (Standard) or Autopilot, sized from measured requests |
| Stateful system | Managed database outside the cluster first; StatefulSet only when you must self-manage |
| Regulated workloads | Standard or Autopilot with Workload Identity, Binary Authorization, private nodes, and VPC-native networking |
Implementation Checklist
Trade-offs
Kubernetes is a platform you operate even when Google runs the control plane: upgrades, policy, capacity, and incident response for the cluster layer remain yours. Autopilot trades control for safety and predictable per-pod pricing — the guardrails that protect you also block legitimate edge cases. Regional clusters cost more than zonal ones. And the ecosystem's flexibility means there are always five ways to do anything, so a cluster without team conventions drifts into inconsistency that no managed service can prevent.
When Not to Use
Conclusion
GKE rewards the same discipline as Kubernetes anywhere, with less of the undifferentiated work: pick Autopilot unless you can name the node-level control you need, run regional, keep versions moving on a release channel, and enforce resource and identity hygiene from the first workload. Do that, and the cluster becomes boring infrastructure — which is the highest compliment a platform can earn.
References
Why This Matters
Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.
Trade-offs to Consider
Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.
When NOT to Use This
Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.
Decision Framework
Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.