How to provision a Google GKE cluster and deploy a workload
GKE is Google-managed Kubernetes with Autopilot and Standard modes. Create a cluster with gcloud, get credentials for kubectl, then deploy, expose, and autoscale a workload.
Provisioning a Google GKE cluster
Google Kubernetes Engine (GKE) is Google Cloud's managed Kubernetes, the original home of the project. GKE offers two modes: Autopilot, which manages nodes for you and bills per pod, and Standard, which gives you full control of node pools.
Prerequisites
- A Google Cloud project with billing enabled.
- The
gcloudCLI andkubectlinstalled.
Steps
1. Set the project and enable APIs
gcloud config set project my-project
gcloud services enable container.googleapis.com
2. Choose Autopilot or Standard
Pick Autopilot for a hands-off, pod-billed experience; pick Standard when you need specific machine types, GPUs, or fine node control.
3. Create the cluster
Standard mode with autoscaling:
gcloud container clusters create demo \
--region us-central1 \
--num-nodes 1 \
--enable-autoscaling --min-nodes 1 --max-nodes 5
For Autopilot: gcloud container clusters create-auto demo --region us-central1.
4. Get cluster credentials
gcloud container clusters get-credentials demo --region us-central1
kubectl get nodes
5. Deploy and expose a workload
kubectl create deployment web --image=nginx --replicas=3
kubectl expose deployment web --port=80 --type=LoadBalancer
kubectl get svc web --watch
Google Cloud provisions an external load balancer.
6. Enable node autoscaling
Standard clusters use the flags above; Autopilot scales automatically. Combine with an HPA for end-to-end elasticity.
Verification
Confirm nodes are Ready and pods Running. Browse to the load balancer IP and confirm the app responds. In the Cloud Console, confirm the cluster and node pool report healthy.
Next Steps
Enable Workload Identity so pods access Google Cloud APIs securely, use GKE Ingress or the Gateway API for HTTP routing, and store images in Artifact Registry. Codify the cluster in Terraform, and delete demo clusters with gcloud container clusters delete demo --region us-central1 to avoid charges.
Prerequisites
- A Google Cloud project with billing
- gcloud CLI installed
- kubectl installed
Steps
- 1Set the project and enable APIs
- 2Choose Autopilot or Standard
- 3Create the cluster
- 4Get cluster credentials
- 5Deploy and expose a workload
- 6Enable node autoscaling