Getting Started with Google Kubernetes Engine (GKE): Clusters, Deployments & Autoscaling

By Mesue Collins Asibong • Cloud & Kubernetes • 7 min read Getting Started with Google Kubernetes Engine GKE

Google Kubernetes Engine (GKE) provides a fully managed environment for deploying, managing, and scaling containerized applications on Google Cloud. By offloading control-plane management (the Kubernetes API server, etcd, and scheduler) to Google SREs, engineering teams can focus entirely on shipping resilient microservices.

Based on my introductory Kubernetes session with Google Developer Groups (GDG Cloud), this guide walks through choosing between GKE Autopilot and Standard modes, provisioning your first cluster, deploying a containerized web application, and configuring automatic scaling with a HorizontalPodAutoscaler (HPA).

Core GKE Workload & Service Architecture

flowchart LR classDef gcp fill:#4285F4,stroke:#fff,stroke-width:2px,color:#fff classDef k8s fill:#326ce5,stroke:#fff,stroke-width:2px,color:#fff classDef pod fill:#34a853,stroke:#fff,stroke-width:2px,color:#fff Users(["Internet Traffic"]) --> GCLB["Cloud Load Balancer"]:::gcp subgraph GKECluster ["GKE Cluster"] GCLB --> Svc["Service Type LoadBalancer"]:::k8s Deploy["Deployment Controller"]:::k8s -->|Manages ReplicaSet| P1["Pod Replica 1"]:::pod Deploy -->|Manages ReplicaSet| P2["Pod Replica 2"]:::pod Deploy -->|Manages ReplicaSet| P3["Pod Replica 3"]:::pod Svc --> P1 & P2 & P3 HPA["Horizontal Pod Autoscaler"]:::k8s -.->|Scales 3 to 10 Pods| Deploy end

Step 1: GKE Autopilot vs. Standard Mode

When creating a GKE cluster, Google Cloud offers two modes of operation:

  • GKE Autopilot (Recommended for most workloads): Google provisions and manages the underlying worker nodes automatically, pre-configured with security best practices (Workload Identity, Shielded Nodes, and Seccomp profiles). You pay only for the CPU, memory, and ephemeral storage requested by your running Pods.
  • GKE Standard: Gives you direct control over node pools, machine types, and host-level kernel configurations, ideal when you need specialized node customization.

Step 2: Provisioning a GKE Autopilot Cluster

We start by enabling the Kubernetes Engine API, creating a regional GKE Autopilot cluster using gcloud container clusters create-auto, and fetching cluster credentials so kubectl can communicate with the control plane:

export PROJECT_ID=$(gcloud config get-value project)
export CLUSTER_NAME="gke-starter-cluster"
export REGION="us-central1"

# Enable the Google Kubernetes Engine API
gcloud services enable container.googleapis.com

# Create a regional GKE Autopilot cluster
gcloud container clusters create-auto $CLUSTER_NAME \
    --region=$REGION \
    --project=$PROJECT_ID \
    --release-channel=regular

# Configure kubectl authentication via gke-gcloud-auth-plugin
gcloud container clusters get-credentials $CLUSTER_NAME --region=$REGION

Step 3: Deploying a Containerized Application & Service

In Kubernetes, we rarely create bare Pods directly. Instead, we declare a Deployment (which maintains the desired number of Pod replicas and handles rolling updates) and a Service (which provides a stable IP address and load balances traffic across healthy Pods).

Notice that we explicitly define resources.requests and resources.limits—this allows GKE Autopilot to right-size the compute capacity for each Pod:

# app-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-cloud-web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello-cloud
  template:
    metadata:
      labels:
        app: hello-cloud
    spec:
      containers:
      - name: web-server
        image: us-docker.pkg.dev/google-samples/containers/gke/hello-app:2.0
        ports:
        - containerPort: 8080
        resources:
          requests:
            cpu: "250m"
            memory: "512Mi"
          limits:
            cpu: "500m"
            memory: "512Mi"
---
apiVersion: v1
kind: Service
metadata:
  name: hello-cloud-service
spec:
  type: LoadBalancer
  selector:
    app: hello-cloud
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080

Apply the manifest and verify that the pods and external LoadBalancer IP are ready:

kubectl apply -f app-deployment.yaml
kubectl get pods -l app=hello-cloud
kubectl get service hello-cloud-service --watch

Step 4: Configuring Horizontal Pod Autoscaling (HPA)

To handle sudden traffic spikes automatically, we configure a HorizontalPodAutoscaler. When average CPU utilization across our Pods exceeds 70%, GKE automatically scales the Deployment up to 10 replicas, and scales back down when traffic subsides:

kubectl autoscale deployment hello-cloud-web \
    --cpu-percent=70 \
    --min=3 \
    --max=10

# Inspect the HorizontalPodAutoscaler status
kubectl get hpa hello-cloud-web

Summary

With GKE Autopilot, declarative `Deployment` and `Service` manifests, and Horizontal Pod Autoscaling, you can take any containerized application from a single image in Artifact Registry to a self-healing, auto-scaling service backed by Google Cloud Load Balancing in minutes.