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.
https://napo.io/posts/terraform-kubernetes-multi-cloud-ack-aks-dok-eks-gke-oke/#google-cloud
- Terraform Kubernetes on Google Cloud
- Requirements
- Features
- Notes
- Defaults
- Runtime
- Terraform Inputs
- Outputs
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 ofgke_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
:
~5-6min
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
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) | "https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/monitoring" | no |
Name | Description |
---|---|
kubeconfig_path_gke | Kubernetes kubeconfig file |
latest_k8s_master_version | Latest Kubernetes master Version available in Google Cloud location |