Skip to content

Instantly share code, notes, and snippets.

@cassanellicarlo
Created November 10, 2020 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cassanellicarlo/77446c230a07d75f2c2e34a0c4d1f81d to your computer and use it in GitHub Desktop.
Save cassanellicarlo/77446c230a07d75f2c2e34a0c4d1f81d to your computer and use it in GitHub Desktop.
Terraform - Google Cloud Kubernetes Cluster
resource "google_container_cluster" "primary" {
name = "my-gke-cluster"
location = "us-central1"
# We can't create a cluster with no node pool defined, but we want to only use
# separately managed node pools. So we create the smallest possible default
# node pool and immediately delete it.
remove_default_node_pool = true
initial_node_count = 1
master_auth {
username = ""
password = ""
client_certificate_config {
issue_client_certificate = false
}
}
}
resource "google_container_node_pool" "primary_preemptible_nodes" {
name = "my-node-pool"
location = "us-central1"
cluster = google_container_cluster.primary.name
node_count = 1
node_config {
preemptible = true
machine_type = "e2-medium"
metadata = {
disable-legacy-endpoints = "true"
}
oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment