DEV Community

Cover image for Part-123: 🚀Create a GKE Autopilot Cluster and Deploy an Application
Latchu@DevOps
Latchu@DevOps

Posted on

Part-123: 🚀Create a GKE Autopilot Cluster and Deploy an Application

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:

  1. Create a GKE Autopilot Cluster
  2. Understand how Autopilot works under the hood
  3. 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.

a1


💻 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"
Enter fullscreen mode Exit fullscreen mode

🧠 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
Enter fullscreen mode Exit fullscreen mode

Verify Access

# List Nodes
kubectl get nodes

# List System Pods
kubectl get pods -n kube-system
Enter fullscreen mode Exit fullscreen mode

a2

✅ 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"
Enter fullscreen mode Exit fullscreen mode

📄 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
Enter fullscreen mode Exit fullscreen mode

🚀 Step 05: Deploy Kubernetes Manifests

# Deploy manifests
kubectl apply -f kube-manifests/

# List deployments
kubectl get deploy

# List pods
kubectl get pods
Enter fullscreen mode Exit fullscreen mode

a2

🕒 Observation:

  1. Pods may take 2–3 minutes to move from Pending → Running.
  2. GKE Autopilot automatically provisions nodes as needed.

Verify Services

kubectl get svc
Enter fullscreen mode Exit fullscreen mode

Verify Nodes

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

a3

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
Enter fullscreen mode Exit fullscreen mode

✅ You’ll notice that GKE automatically provisions additional nodes to meet the workload requirements.

a4


🧹 Step 07: Clean-Up

When you’re done testing:

# Delete application resources
kubectl delete -f kube-manifests/
Enter fullscreen mode Exit fullscreen mode

Verify Cluster Scaling Down

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)