This content originally appeared on DEV Community and was authored by Latchu@DevOps
In this tutorial, weβll walk through how to create a Google Kubernetes Engine (GKE) Autopilot cluster, deploy a sample application, and understand how GKE Autopilot manages infrastructure for you.
Autopilot mode lets you focus entirely on your workloads β while Google handles the node provisioning, scaling, and security patching automatically.
Step 01: Introduction
Weβll perform the following tasks:
- Create a GKE Autopilot Cluster
- Understand how Autopilot works under the hood
- Deploy a sample NGINX app and test it
What is GKE Autopilot?
- A fully managed Kubernetes mode by Google.
- You donβt manage nodes β GKE provisions, scales, and maintains them.
- You only pay for running pods, not idle nodes.
- It enforces best practices for security, networking, and reliability.
Step 02: Create a GKE Autopilot Cluster
Navigate to:
Kubernetes Engine β Clusters β CREATE
Then choose:
GKE Autopilot β CONFIGURE
Cluster Basics
Setting | Value |
---|---|
Name | autopilot-cluster-public-1 |
Region | us-central1 |
Leave the remaining fields as defaults.
Fleet Registration
Leave to defaults.
Networking
Setting | Value |
---|---|
Network | default |
Node subnet | default |
IPv4 Network Access | Public cluster |
Access control plane using external IP | Checked (default) |
Control plane IP range | 172.18.0.0/28 |
Advanced Settings
Leave all to defaults and click CREATE.
Equivalent gcloud Command
gcloud container clusters create-auto "autopilot-cluster-public-1" \
--region "us-central1" \
--master-ipv4-cidr "172.18.0.0/28" \
--network "default" \
--subnetwork "default"
Step 03: Access the Autopilot Cluster from Cloud Shell
Once the cluster is created, configure your kubectl context.
# Configure kubeconfig
gcloud container clusters get-credentials autopilot-cluster-public-1 --region us-central1 --project gcp-zero-to-hero-468909
Verify Access
# List Nodes
kubectl get nodes
# List System Pods
kubectl get pods -n kube-system
You should see your system pods and automatically managed nodes listed.
Step 04: Review Kubernetes Manifests
Weβll deploy a simple NGINX app to test the cluster.
Step 04-01: Deployment (01-kubernetes-deployment.yaml)
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp1-deployment
spec:
replicas: 5
selector:
matchLabels:
app: myapp1
template:
metadata:
labels:
app: myapp1
spec:
containers:
- name: myapp1-container
image: ghcr.io/stacksimplify/kubenginx:1.0.0
ports:
- containerPort: 80
resources:
requests:
memory: "128Mi"
cpu: "200m"
limits:
memory: "256Mi"
cpu: "400m"
Step 04-02: Service (02-kubernetes-loadbalancer-service.yaml)
apiVersion: v1
kind: Service
metadata:
name: myapp1-lb-service
spec:
type: LoadBalancer
selector:
app: myapp1
ports:
- name: http
port: 80
targetPort: 80
Step 05: Deploy Kubernetes Manifests
# Deploy manifests
kubectl apply -f kube-manifests/
# List deployments
kubectl get deploy
# List pods
kubectl get pods
Observation:
- Pods may take 2β3 minutes to move from Pending β Running.
- GKE Autopilot automatically provisions nodes as needed.
Verify Services
kubectl get svc
Verify Nodes
kubectl get nodes
Observation:
- Nodes are dynamically created by GKE.
- You canβt see these nodes under Compute Engine β VM Instances.
- Theyβre fully managed by GKE.
Access the Application
Copy the External IP from the LoadBalancer service output and open in a browser:
http://<EXTERNAL-IP>
You should see the NGINX welcome page.
Step 06: Scale the Application
Autopilot clusters scale seamlessly as demand grows.
# Scale the deployment
kubectl scale --replicas=15 deployment/myapp1-deployment
# Verify pods
kubectl get pods
# Verify nodes
kubectl get nodes
Youβll notice that GKE automatically provisions additional nodes to meet the workload requirements.
Step 07: Clean-Up
When youβre done testing:
# Delete application resources
kubectl delete -f kube-manifests/
Verify Cluster Scaling Down
kubectl get nodes
Observation:
After 5β10 minutes, GKE will automatically de-provision unused nodes.
Summary
Step | Description |
---|---|
1 | Created an Autopilot GKE Cluster |
2 | Deployed a sample NGINX app |
3 | Observed automatic scaling and node management |
4 | Cleaned up resources and cluster |
Key Takeaways
- GKE Autopilot automates cluster operations, freeing you from node management.
- You only pay for running pods, making it cost-efficient.
- Resources like CPU/memory are automatically optimized.
- Scaling and node provisioning are completely managed by Google.
Thanks for reading! If this post added value, a like
, follow, or share would encourage me to keep creating more content.
β Latchu | Senior DevOps & Cloud Engineer
AWS | GCP |
Kubernetes |
Security |
Automation
Sharing hands-on guides, best practices & real-world cloud solutions
This content originally appeared on DEV Community and was authored by Latchu@DevOps