Terraformterraformgcpgkekubernetesproduction-ready
GKE Cluster Configuration
Google Kubernetes Engine cluster with node pools, workload identity, network policies, and cluster autoscaling.
title: "GKE Cluster Configuration" description: "Google Kubernetes Engine cluster with node pools, workload identity, network policies, and cluster autoscaling." category: "Terraform" language: "hcl" tags: ["terraform", "gcp", "gke", "kubernetes", "production-ready"] createdAt: "2025-03-25" updatedAt: "2025-04-10"
Overview
A production GKE cluster with private nodes, Workload Identity for secure GCP API access, network policies, cluster autoscaling, and separate node pools for general workloads and cost-optimized spot instances.
Code
module "gke" {
source = "./modules/gke"
project_id = "my-project"
cluster_name = "production"
region = "us-central1"
}Notes
- Private cluster nodes have no public IPs, reducing attack surface
- Workload Identity maps Kubernetes service accounts to GCP service accounts (no key files)
- Spot node pool with taints ensures only tolerant workloads (batch jobs) schedule there
- Maintenance windows restrict auto-upgrades to weekends during low traffic
REGULARrelease channel provides stable versions with security patches