diff --git a/tf-environments/gcp/dev/_env_defaults/gcp.tfvars b/tf-environments/gcp/dev/_env_defaults/gcp.tfvars index 6e2e8513b..1fb82dffb 100644 --- a/tf-environments/gcp/dev/_env_defaults/gcp.tfvars +++ b/tf-environments/gcp/dev/_env_defaults/gcp.tfvars @@ -1,2 +1,6 @@ region = "us-central1" project_name = "managedkube" + +# regional cluster with 3 masters use the region with the zone (eg. us-central1). This cost $0.10/hour. +# zonal cluster that has only one master and in one zone. Add the zone to the region. (eg. us-central1-a). There is no GCP charge for this. +google_container_cluster_location = "us-central1-a" \ No newline at end of file diff --git a/tf-environments/gcp/dev/nodepools/pool-1/terragrunt.hcl b/tf-environments/gcp/dev/nodepools/pool-1/terragrunt.hcl index 5de9d41aa..f163720da 100644 --- a/tf-environments/gcp/dev/nodepools/pool-1/terragrunt.hcl +++ b/tf-environments/gcp/dev/nodepools/pool-1/terragrunt.hcl @@ -17,6 +17,7 @@ terraform { inputs = { cluster_name = trimspace(run_cmd("terragrunt", "output", "cluster_name", "--terragrunt-working-dir", "../../gke-cluster")) + node_pool_name = "pool-1" initial_node_count = "1" diff --git a/tf-modules/gcp/nodepool/main.tf b/tf-modules/gcp/nodepool/main.tf index 39b5775f0..50895b25c 100644 --- a/tf-modules/gcp/nodepool/main.tf +++ b/tf-modules/gcp/nodepool/main.tf @@ -13,7 +13,7 @@ provider "google-beta" { resource "google_container_node_pool" "node_nodes" { provider = google-beta name = var.node_pool_name - location = var.region + location = var.google_container_cluster_location cluster = var.cluster_name node_count = var.initial_node_count autoscaling { diff --git a/tf-modules/gcp/nodepool/vars.tf b/tf-modules/gcp/nodepool/vars.tf index 09213281a..8d3536d5c 100644 --- a/tf-modules/gcp/nodepool/vars.tf +++ b/tf-modules/gcp/nodepool/vars.tf @@ -10,6 +10,10 @@ variable "credentials_file_path" { description = "A local path to a service account json credentials file." } +variable "google_container_cluster_location" { + description = "Location of the cluster to make it a regional or zonal cluster" +} + variable "cluster_name" { default = "dev" } diff --git a/tf-modules/gcp/private-gke-cluster/main.tf b/tf-modules/gcp/private-gke-cluster/main.tf index 6cf89a825..0baae74bc 100644 --- a/tf-modules/gcp/private-gke-cluster/main.tf +++ b/tf-modules/gcp/private-gke-cluster/main.tf @@ -20,7 +20,7 @@ provider "google-beta" { resource "google_container_cluster" "primary" { provider = google-beta name = var.cluster_name - location = var.region + location = var.google_container_cluster_location node_version = var.gke_version min_master_version = var.gke_version network = var.network_name diff --git a/tf-modules/gcp/private-gke-cluster/vars.tf b/tf-modules/gcp/private-gke-cluster/vars.tf index 3710d7b81..29e6aa601 100644 --- a/tf-modules/gcp/private-gke-cluster/vars.tf +++ b/tf-modules/gcp/private-gke-cluster/vars.tf @@ -27,6 +27,10 @@ variable "private_subnet_name" { description = "The name of the private subnet to use" } +variable "google_container_cluster_location" { + description = "Location of the cluster to make it a regional or zonal cluster" +} + ##################################### ##################################### variable "cluster_name" {