Skip to content
Terraform module for creating a Kubernetes cluster on Google Cloud Platform with latest available version, kubeconfig file creation and addititonal node pool.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Terraform Kubernetes on Google Cloud

This repository contains the Terraform module for creating a simple but ready-to-use Kubernetes Cluster on Google Cloud Kubernetes Engine (GKE).

It uses the latest available Kubernetes version available in the Google Cloud location and creates a kubeconfig file at completion.

Link to my comprehensive blog post (beginner friendly):

Google Cloud Logo


You need a Google Cloud account with billing enabled (if you already exceeded the Trial).


  • Always uses latest Kubernetes version available at Google Cloud location
  • kubeconfig file generation
  • Master nodes are available from workstation IP address only (master_authorized_networks_config)
  • Create zonal (default) or regional GKE cluster (enable_regional_cluster)


  • export KUBECONFIG=./kubeconfig_gke in repo root dir to use the generated kubeconfig file
  • If you want to create a regional cluster set enable_regional_cluster to true (keep in mind that number of gke_nodes will be deployed in every zone - e.g. 3 zones in a region * 2 gke_nodes => 6 worker nodes)
  • The enable_google variable is used in the hajowieland/terraform-kubernetes-multi-cloud module


See tables at the end for a comprehensive list of inputs and outputs.

  • Default region: europe-west3 (Frankfurt, Germany)
  • Default node type: n1-standard-2 (1x vCPU, 7.5GB memory)
  • Default node pool size: 2


terraform apply:


4.28s user
1.11s system
4:58.60 total
4.72s user
1.39s system
5:03.16 total
4.74s user
1.40s system
5:34.30 total

Terraform Inputs

Name Description Type Default Required
enable_google Enable / Disable Google Cloud k8s bool true yes
enable_regional_cluster Create regional GKE cluster instead of zonal bool true no
random_cluster_suffix Random 6 byte hex suffix for cluster name string no
gcp_project GCP Project ID string yes
gcp_region GCP region string europe-west3 no
gke_name GKE cluster name string k8s no
gke_pool_name GKE node pool name string k8snodepool no
gke_nodes GKE Kubernetes worker nodes number 2 no
gke_preemptible Use GKE preemptible nodes bool false no
gke_node_type GKE node instance type string n1-standard-2 no
gke_serviceaccount GCP service account for GKE string default no
gke_oauth_scopes GCP OAuth scopes for GKE list(string) "", "", "", "" no


Name Description
kubeconfig_path_gke Kubernetes kubeconfig file
latest_k8s_master_version Latest Kubernetes master Version available in Google Cloud location
You can’t perform that action at this time.