Last active
September 23, 2021 21:49
-
-
Save TylerWanner/5a7888e7a31f844a24c3f20198ea645f to your computer and use it in GitHub Desktop.
Demo GKE Cluster Specs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
backend "local" { | |
path = "../states/cluster.tfstate" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zone = "us-central1-b" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "google_container_cluster" "cluster" { | |
name = "demo-cluster" | |
release_channel { | |
channel = "REGULAR" | |
} | |
remove_default_node_pool = true | |
# 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. | |
initial_node_count = 1 | |
# Setting an empty username and password explicitly disables basic auth | |
master_auth { | |
username = "" | |
password = "" | |
client_certificate_config { | |
issue_client_certificate = false | |
} | |
} | |
logging_service = "logging.googleapis.com/kubernetes" | |
monitoring_service = "monitoring.googleapis.com/kubernetes" | |
} | |
resource "google_container_node_pool" "nodes" { | |
lifecycle { | |
create_before_destroy = true | |
ignore_changes = [ | |
# https://registry.terraform.io/providers/hashicorp/google/3.35.0/docs/resources/container_node_pool#initial_node_count | |
initial_node_count | |
] | |
} | |
name_prefix = "pool" | |
location = google_container_cluster.cluster.location | |
cluster = google_container_cluster.cluster.name | |
initial_node_count = 2 | |
management { | |
auto_repair = true | |
auto_upgrade = true | |
} | |
autoscaling { | |
min_node_count = 2 | |
max_node_count = 4 | |
} | |
node_config { | |
preemptible = true | |
metadata = { | |
disable-legacy-endpoints = "true" | |
} | |
workload_metadata_config { | |
node_metadata = "SECURE" | |
} | |
machine_type = "e2-standard-2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output cluster_endpoint { | |
value = google_container_cluster.cluster.endpoint | |
} | |
output cacert { | |
value = google_container_cluster.cluster.master_auth[0].cluster_ca_certificate | |
} | |
output project { | |
value = var.project | |
} | |
output zone { | |
value = var.zone | |
} | |
output cluster_name { | |
value = google_container_cluster.cluster.name | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider google { | |
project = var.project | |
zone = var.zone | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "zone" {} | |
variable "project" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_providers { | |
google = { | |
source = "hashicorp/google" | |
version = "3.85.0" | |
} | |
} | |
required_version = ">= 1" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment