/tf-gke

Terraform module for setup and lifecycle of a GKE stack

Primary LanguageHCL

Deploy GKE Test Cluster

Creates a GKE test cluster on Google Cloud Compute, outputs kubectl config for access

Requires gcloud cli setup and application default token

Install gcloud

https://cloud.google.com/sdk/docs/install

gcloud init

Run gcloud init and create a new gcp project

Your new gcp project ID will be needed later.

gcloud init

Enable gcloud ADP login which Terraform will use

gcloud auth application-default login

Enable billing account for your new project

The GCP proejct will also need billing enabled and a valid credit card. Ideally the base install provided by this module will be in the free tier but based upon your usage this may not be the case. Depending on what you deploy to the test cluster. https://cloud.google.com/billing/docs/how-to/modify-project

Enable GCP APIs for project

In order to operate you must activate the following APIs on your GCP project:

gcloud projects list
gcloud config set project YOUR_GPC_PROJECT_ID
gcloud services list --available
gcloud services enable container.googleapis.com
gcloud services enable compute.googleapis.com

Update Terraform project_id inputs with your project_id

Replace YOUR_GCP_PROJECT_ID in google-provider.tf Replace YOUR_GCP_PROJECT_ID in variables.tf

Run Terraform

terraform init
terraform plan
terraform apply

Requirements

Name Version
terraform >= 0.13
google ~> 4.0

Providers

Name Version
google 4.25.0
kubernetes 2.11.0

Modules

Name Source Version
gcp-network terraform-google-modules/network/google >= 4.0.1, < 5.0.0
gke terraform-google-modules/kubernetes-engine/google n/a
gke_auth terraform-google-modules/kubernetes-engine/google//modules/auth n/a

Resources

Name Type
kubernetes_pod.nginx-example resource
kubernetes_service.nginx-example resource
google_client_config.default data source

Inputs

Name Description Type Default Required
project_id The project ID to host the cluster in string "YOUR_GCP_PROJECT_ID" no
region The region the cluster in string "us-central1" no

Outputs

Name Description
cluster_name Cluster name
kubeconfig_raw n/a
location n/a
network_name The name of the VPC being created
project_id The project ID the cluster is in
region The region in which the cluster resides
service_account The service account to default running nodes as if not overridden in node_pools.
subnet_names The names of the subnet being created
zones List of zones in which the cluster resides

TODO

  • Improve docs for quick and easy setup for new GCP user
  • Validate free tier costs and document
  • Add a LoadBalancer service entry point for nginx-demo app to test with (public facing)