Ganpati
How to Deploy a Kubernetes Cluster on Google Kubernetes Engine (GKE) – Complete Step-by-Step Guide

How to Deploy a Kubernetes Cluster on Google Kubernetes Engine (GKE) – Complete Step-by-Step Guide

img

Jatin Panchal

Managing Director

Published on 30 July, 2026

| Last Updated on 06 August, 2026

Published on 30 July, 2026

| Last Updated on 06 August, 2026

Share

How to Deploy a Kubernetes Cluster on Google Kubernetes Engine (GKE) – Complete Step-by-Step Guide

Introduction

When single-instance virtual machines start reaching their limits during traffic spikes, managing containers individually on bare VMs quickly becomes an operational headache. That is usually the exact moment engineering teams transition to Kubernetes.

Kubernetes automates the deployment, scaling, and management of containerized applications. Instead of SSHing into individual nodes to start containers or fix failed processes, you declare your application’s desired state how many replicas it needs, its memory limits, and how traffic should route to it and Kubernetes maintains that state automatically.

While you can run Kubernetes on virtually any infrastructure, Google Cloud Platform (GCP) is a natural fit. Google originally created the internal system (Borg) that inspired Kubernetes, and its managed offering, Google Kubernetes Engine (GKE), offloads the heavy lifting of control plane maintenance, security patching, and node provisioning.

Why GKE over a Self-Managed Cluster?

Unless you have strict on-premises compliance rules or custom kernel requirements, self-managing Kubernetes in production is rarely worth the operational cost. Running raw Kubernetes on Compute Engine VMs means you are personally responsible for:

  • High availability and backups of the etcd key-value store
  • Upgrading and patching the API server and control plane binaries
  • Recovery procedures when a master node fails

GKE handles the control plane management for you, allowing you to focus purely on configuring workloads.

Prerequisites

Before starting, make sure you have the following ready:

  • A GCP account with an active billing account linked
  • The gcloud CLI installed on your local machine
  • kubectl installed (via gcloud components install kubectl or your OS package manager)
  • Basic familiarity with Docker containers and terminal commands
  • IAM permissions equivalent to Kubernetes Engine Admin (roles/container.admin)

Step 1: Create and Set Your GCP Project

All GCP resources must belong to a project. Create a new project for this walkthrough:

gcloud projects create my-gke-demo-2026 --name="GKE Demo Project";

Note: Project IDs must be globally unique across all of Google Cloud.

Set this project as your CLI default so you don’t have to append –project to every subsequent command:

gcloud config set project my-gke-demo-2026

Step 2: Enable the Kubernetes Engine API

GCP disables most service APIs by default to prevent accidental resource usage. Enable the GKE API before attempting cluster creation:

gcloud services enable container.googleapis.com

Step 3: Authenticate the CLI

Authenticate your local machine to interact with your GCP account:

gcloud auth login

Production Security Note: If you are automating this process inside a CI/CD pipeline (e.g., GitHub Actions or GitLab CI), avoid downloading static JSON service account keys. Long-lived keys pose a significant security risk if leaked. Instead, configure Workload Identity Federation to grant temporary, short-lived credentials to your pipeline.

Step 4: Create the GKE Cluster

GKE offers two operational modes:

  • Autopilot: Fully managed. Google manages the nodes, scaling, and security baseline. You pay strictly for the CPU, memory, and storage requested by your Pods.
  • Standard: You maintain control over the node pool configuration, machine types, and autoscaling thresholds.

Run the following command to provision a 3-node Standard cluster across a single zone:

gcloud container clusters create demo-cluster \
--zone=us-central1-a \
--machine-type=e2-medium \
--num-nodes=3

Cost Warning: Standard clusters incur costs for the underlying VM nodes (3 × e2-medium instances cost ~$70–$90/month) plus GKE’s cluster management fee (~$0.10/hour, or ~$72/month after any free-tier credits). Remember to run the cleanup step at the end of this guide to avoid lingering charges.

If you prefer to test with Autopilot mode (where you don’t manage node pools), use this command instead:

gcloud container clusters create-auto demo-autopilot-cluster \
--region=us-central1

Step 5: Connect kubectl to Your Cluster

Once cluster creation completes, pull down the cluster credentials into your local kubeconfig file:

gcloud container clusters get-credentials demo-cluster --zone=us-central1-a

Verify that your local kubectl context is pointing to the cluster and that all worker nodes are ready:

kubectl get nodes

You should see three nodes listed with a status of Ready.

Step 6: Deploy an Application

To verify cluster functionality, deploy a standard NGINX web server using declarative YAML manifests.

Create a file named deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
     matchLabels:
     app: nginx
 template:
   metadata:
   labels:
    app: nginx
 spec:

 containers:
   - name: nginx
     image: nginx:1.27
     ports:
        - containerPort: 80
     resources:
     requests:
      cpu: "100m&quot"
       memory: "128Mi"
  limits:
       cpu: "250m"
      memory: "256Mi"

Apply the deployment:

kubectl apply -f deployment.yaml

Key Configuration Choices

  • Explicit Tag (nginx:1.27): Avoid using :latest in production. Explicit tags ensure predictable deployments across pod restarts.
  • Resource Requests & Limits: Explicitly defining CPU and memory requirements allows the Kubernetes scheduler to place Pods efficiently without starving host nodes.

Step 7: Expose the Application to External Traffic

To allow external web traffic to reach your application, expose the deployment through a Cloud Load Balancer.

Create a file named service.yaml:

apiVersion: v1
kind: Service
metadata:
 name: nginx-service
spec:
 type: LoadBalancer
 selector:
   app: nginx

ports:
  - port: 80
    targetPort: 80

Apply the service manifest:

kubectl apply -f service.yaml

Check the service status:

kubectl get service nginx-service --watch

After a minute or two, GCP will provision an external network load balancer and assign a public IP under the EXTERNAL-IP column. Open that IP address in your browser to verify the NGINX welcome page.

Step 8: Scaling the Workload

You can manually scale your replica count with a single command:

kubectl scale deployment nginx-deployment --replicas=5

For dynamic scaling based on real-time traffic, attach a Horizontal Pod Autoscaler (HPA):

kubectl autoscale deployment nginx-deployment --min=2 --max=10 --cpu-percent=70

This configuration instructs Kubernetes to maintain average CPU utilization near 70% by scaling the replica count between 2 and 10 Pods.

Step 9: Inspection and Debugging

When troubleshooting Pods or deployment issues, rely on these fundamental commands:

# View application output logs
kubectl logs -l app=nginx

# Inspect cluster events and container failure reasons
kubectl describe pod -l app=nginx

# View chronological cluster events (useful for identifying scheduling failures)
kubectl get events --sort-by=.metadata.creationTimestamp

Troubleshooting Tip: If a Pod remains stuck in Pending status, check node resource availability (kubectl describe nodes). This usually means your resource requests exceed the available capacity on your worker nodes, requiring either smaller request limits or larger node pools.

Step 10: Perform a Zero-Downtime Rolling Update

To update your application image without dropping incoming connections:

kubectl set image deployment/nginx-deployment nginx=nginx:1.28

Kubernetes will incrementally replace old Pods with new ones. If the new image fails or crashes on startup, instantly roll back to the previous stable state:

kubectl rollout undo deployment/nginx-deployment

Step 11: Clean Up Resources

To avoid incurring ongoing charges for compute nodes and external load balancers, tear down the resources when you are finished testing:

# 1. Delete the service to release the Cloud Load Balancer IP
kubectl delete service nginx-service

# 2. Delete the cluster and worker VMs
gcloud container clusters delete demo-cluster --zone=us-central1-a

Architecture Comparison: Autopilot vs. Standard vs. Self-Managed

Architecture Comparison Autopilot vs. Standard vs. Self-Managed

Common Troubleshooting Quick Reference

Common Troubleshooting Quick Reference

Conclusion

Setting up a cluster on Google Cloud gives you a resilient foundation for running containerized workloads without the maintenance headaches of raw infrastructure.

From here, the logical next steps for production readiness are:

  • Setting up Helm for managing complex application templates.
  • Configuring Ingress controllers (such as the GKE Gateway API) to route traffic to multiple services through a single IP address.
  • Establishing GitOps pipelines (using tools like ArgoCD or Flux) to manage cluster state directly from a Git repository.

Need expert assistance with Kubernetes, Google Cloud, or cloud-native application deployment? Our team can help you design, deploy, and manage scalable infrastructure. Contact us today: https://www.rlogical.com/contact/

 

img

Jatin Panchal

Managing Director

Jatin Panchal is an innovation-driven entrepreneur, and the Founder & Managing Director of Rlogical Techsoft Pvt. Ltd. He believes modern leadership is driven by innovation, adaptability, and the transformative power of Artificial Intelligence. He focuses on helping businesses accelerate digital growth through AI-powered solutions, intelligent automation, Cloud, blockchain, IoT, and scalable enterprise technologies. With a strong strategic vision and future-focused mindset, he is passionate about building technology ecosystems that improve efficiency, drive innovation, and create long-term business value for global clients.

Read Blog Articles

Global insights on technology trends, best practices, and digital transformation strategies.

View All Blogs
Flutter 3.47: New Features, Improvements, and What Developers Should Know
Flutter App Development Flutter 3.47: New Features, Improvements, and What Developers Should Know
Flutter 3.47 introduces important changes to the framework,…
PHP Security Update October 2026: Critical Vulnerabilities, Fixed Versions & Upgrade Guide
PHP Development PHP Security Update October 2026: Critical Vulnerabilities, Fixed Versions & Upgrade Guide
On October 21, 2026, the official PHP development…
Cloud Migration for Modern Enterprises: Strategy, Framework, Risks, and Best Practices
Cloud Services Cloud Migration for Modern Enterprises: Strategy, Framework, Risks, and Best Practices
Traditional enterprise IT environments often reach a point…