How to Create Terraform code for GKE cluster

4/22/2020

We can create/see the gcloud command from GKE cluster creation UI , is there a way to convert the command into terraform code for GKE cluster. thanks

-- Ijaz Ahmad Khan
google-cloud-platform
google-kubernetes-engine
kubernetes
terraform

1 Answer

4/22/2020

You can create GKE cluster by using terraform. There is a official link, by following you need to write the .tf file and apply.

resource "google_container_cluster" "primary" {
  name     = "my-gke-cluster"
  location = "us-central1"

  initial_node_count       = 1

  master_auth {
    username = ""
    password = ""

    client_certificate_config {
      issue_client_certificate = false
    }
  }
}

This is an useful tutorial.

-- hoque
Source: StackOverflow