From 1d459d7d71f2403aa753a359b14bfff5b99c1db0 Mon Sep 17 00:00:00 2001 From: Adrian Chifor Date: Fri, 21 Jan 2022 12:00:23 +0000 Subject: [PATCH 1/6] Add spot vm support to beta clusters --- modules/beta-private-cluster-update-variant/README.md | 2 ++ modules/beta-private-cluster-update-variant/cluster.tf | 2 ++ modules/beta-private-cluster/README.md | 2 ++ modules/beta-private-cluster/cluster.tf | 1 + modules/beta-public-cluster-update-variant/README.md | 2 ++ modules/beta-public-cluster-update-variant/cluster.tf | 2 ++ modules/beta-public-cluster/README.md | 2 ++ modules/beta-public-cluster/cluster.tf | 1 + 8 files changed, 14 insertions(+) diff --git a/modules/beta-private-cluster-update-variant/README.md b/modules/beta-private-cluster-update-variant/README.md index bebc836f4b..4712f997d7 100644 --- a/modules/beta-private-cluster-update-variant/README.md +++ b/modules/beta-private-cluster-update-variant/README.md @@ -93,6 +93,7 @@ module "gke" { auto_upgrade = true service_account = "project-service-account@.iam.gserviceaccount.com" preemptible = false + spot = false initial_node_count = 80 }, ] @@ -327,6 +328,7 @@ The node_pools variable takes the following parameters: | node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional | | node_metadata | Options to expose the node metadata to the workload running on the node | | Optional | | preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional | +| spot | A boolean that represents whether the underlying node VMs are spot | false | Optional | | sandbox_type | Sandbox to use for pods in the node pool | | Required | | service_account | The service account to be used by the Node VMs | " " | Optional | | tags | The list of instance tags applied to all nodes | | Required | diff --git a/modules/beta-private-cluster-update-variant/cluster.tf b/modules/beta-private-cluster-update-variant/cluster.tf index 9ce5a921a0..e8622e4292 100644 --- a/modules/beta-private-cluster-update-variant/cluster.tf +++ b/modules/beta-private-cluster-update-variant/cluster.tf @@ -367,6 +367,7 @@ locals { "machine_type", "min_cpu_platform", "preemptible", + "spot", "service_account", ] } @@ -548,6 +549,7 @@ resource "google_container_node_pool" "pools" { local.service_account, ) preemptible = lookup(each.value, "preemptible", false) + spot = lookup(each.value, "spot", false) oauth_scopes = concat( local.node_pools_oauth_scopes["all"], diff --git a/modules/beta-private-cluster/README.md b/modules/beta-private-cluster/README.md index e6c45504ed..4cacc99790 100644 --- a/modules/beta-private-cluster/README.md +++ b/modules/beta-private-cluster/README.md @@ -71,6 +71,7 @@ module "gke" { auto_upgrade = true service_account = "project-service-account@.iam.gserviceaccount.com" preemptible = false + spot = false initial_node_count = 80 }, ] @@ -305,6 +306,7 @@ The node_pools variable takes the following parameters: | node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional | | node_metadata | Options to expose the node metadata to the workload running on the node | | Optional | | preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional | +| spot | A boolean that represents whether the underlying node VMs are spot | false | Optional | | sandbox_type | Sandbox to use for pods in the node pool | | Required | | service_account | The service account to be used by the Node VMs | " " | Optional | | tags | The list of instance tags applied to all nodes | | Required | diff --git a/modules/beta-private-cluster/cluster.tf b/modules/beta-private-cluster/cluster.tf index a7bf195713..a524dd9257 100644 --- a/modules/beta-private-cluster/cluster.tf +++ b/modules/beta-private-cluster/cluster.tf @@ -463,6 +463,7 @@ resource "google_container_node_pool" "pools" { local.service_account, ) preemptible = lookup(each.value, "preemptible", false) + spot = lookup(each.value, "spot", false) oauth_scopes = concat( local.node_pools_oauth_scopes["all"], diff --git a/modules/beta-public-cluster-update-variant/README.md b/modules/beta-public-cluster-update-variant/README.md index afa5c27400..d4efd1bc11 100644 --- a/modules/beta-public-cluster-update-variant/README.md +++ b/modules/beta-public-cluster-update-variant/README.md @@ -87,6 +87,7 @@ module "gke" { auto_upgrade = true service_account = "project-service-account@.iam.gserviceaccount.com" preemptible = false + spot = false initial_node_count = 80 }, ] @@ -314,6 +315,7 @@ The node_pools variable takes the following parameters: | node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional | | node_metadata | Options to expose the node metadata to the workload running on the node | | Optional | | preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional | +| spot | A boolean that represents whether the underlying node VMs are spot | false | Optional | | sandbox_type | Sandbox to use for pods in the node pool | | Required | | service_account | The service account to be used by the Node VMs | " " | Optional | | tags | The list of instance tags applied to all nodes | | Required | diff --git a/modules/beta-public-cluster-update-variant/cluster.tf b/modules/beta-public-cluster-update-variant/cluster.tf index c0f2d8d86d..784f6c9ea1 100644 --- a/modules/beta-public-cluster-update-variant/cluster.tf +++ b/modules/beta-public-cluster-update-variant/cluster.tf @@ -348,6 +348,7 @@ locals { "machine_type", "min_cpu_platform", "preemptible", + "spot", "service_account", ] } @@ -529,6 +530,7 @@ resource "google_container_node_pool" "pools" { local.service_account, ) preemptible = lookup(each.value, "preemptible", false) + spot = lookup(each.value, "spot", false) oauth_scopes = concat( local.node_pools_oauth_scopes["all"], diff --git a/modules/beta-public-cluster/README.md b/modules/beta-public-cluster/README.md index c104f36a6c..2967854015 100644 --- a/modules/beta-public-cluster/README.md +++ b/modules/beta-public-cluster/README.md @@ -65,6 +65,7 @@ module "gke" { auto_upgrade = true service_account = "project-service-account@.iam.gserviceaccount.com" preemptible = false + spot = false initial_node_count = 80 }, ] @@ -292,6 +293,7 @@ The node_pools variable takes the following parameters: | node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional | | node_metadata | Options to expose the node metadata to the workload running on the node | | Optional | | preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional | +| spot | A boolean that represents whether the underlying node VMs are spot | false | Optional | | sandbox_type | Sandbox to use for pods in the node pool | | Required | | service_account | The service account to be used by the Node VMs | " " | Optional | | tags | The list of instance tags applied to all nodes | | Required | diff --git a/modules/beta-public-cluster/cluster.tf b/modules/beta-public-cluster/cluster.tf index dc6b439c39..2415e342e8 100644 --- a/modules/beta-public-cluster/cluster.tf +++ b/modules/beta-public-cluster/cluster.tf @@ -444,6 +444,7 @@ resource "google_container_node_pool" "pools" { local.service_account, ) preemptible = lookup(each.value, "preemptible", false) + spot = lookup(each.value, "spot", false) oauth_scopes = concat( local.node_pools_oauth_scopes["all"], From 94f849431526a1b36c3ac09608c0aa02b3e10036 Mon Sep 17 00:00:00 2001 From: Adrian Chifor Date: Fri, 21 Jan 2022 12:21:32 +0000 Subject: [PATCH 2/6] Update autogen, make build --- autogen/main/README.md | 2 ++ autogen/main/cluster.tf.tmpl | 6 ++++++ modules/beta-private-cluster-update-variant/README.md | 2 +- modules/beta-private-cluster-update-variant/cluster.tf | 2 +- modules/beta-private-cluster/README.md | 2 +- modules/beta-private-cluster/cluster.tf | 2 +- modules/beta-public-cluster-update-variant/README.md | 2 +- modules/beta-public-cluster-update-variant/cluster.tf | 2 +- modules/beta-public-cluster/README.md | 2 +- modules/beta-public-cluster/cluster.tf | 2 +- 10 files changed, 16 insertions(+), 8 deletions(-) diff --git a/autogen/main/README.md b/autogen/main/README.md index 1457215e57..214086a466 100644 --- a/autogen/main/README.md +++ b/autogen/main/README.md @@ -95,6 +95,7 @@ module "gke" { max_count = 100 local_ssd_count = 0 {% if beta_cluster %} + spot = false local_ssd_ephemeral_count = 0 {% endif %} disk_size_gb = 100 @@ -212,6 +213,7 @@ The node_pools variable takes the following parameters: | node_metadata | Options to expose the node metadata to the workload running on the node | | Optional | | preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional | {% if beta_cluster %} +| spot | A boolean that represents whether the underlying node VMs are spot | false | Optional | | sandbox_type | Sandbox to use for pods in the node pool | | Required | {% endif %} | service_account | The service account to be used by the Node VMs | " " | Optional | diff --git a/autogen/main/cluster.tf.tmpl b/autogen/main/cluster.tf.tmpl index 3debee4e0d..92f3b799b6 100644 --- a/autogen/main/cluster.tf.tmpl +++ b/autogen/main/cluster.tf.tmpl @@ -409,6 +409,9 @@ locals { "machine_type", "min_cpu_platform", "preemptible", + {% if beta_cluster %} + "spot", + {% endif %} "service_account", ] } @@ -609,6 +612,9 @@ resource "google_container_node_pool" "pools" { local.service_account, ) preemptible = lookup(each.value, "preemptible", false) + {% if beta_cluster %} + spot = lookup(each.value, "spot", false) + {% endif %} oauth_scopes = concat( local.node_pools_oauth_scopes["all"], diff --git a/modules/beta-private-cluster-update-variant/README.md b/modules/beta-private-cluster-update-variant/README.md index 4712f997d7..92c1fb0886 100644 --- a/modules/beta-private-cluster-update-variant/README.md +++ b/modules/beta-private-cluster-update-variant/README.md @@ -85,6 +85,7 @@ module "gke" { min_count = 1 max_count = 100 local_ssd_count = 0 + spot = false local_ssd_ephemeral_count = 0 disk_size_gb = 100 disk_type = "pd-standard" @@ -93,7 +94,6 @@ module "gke" { auto_upgrade = true service_account = "project-service-account@.iam.gserviceaccount.com" preemptible = false - spot = false initial_node_count = 80 }, ] diff --git a/modules/beta-private-cluster-update-variant/cluster.tf b/modules/beta-private-cluster-update-variant/cluster.tf index e8622e4292..c6a9614401 100644 --- a/modules/beta-private-cluster-update-variant/cluster.tf +++ b/modules/beta-private-cluster-update-variant/cluster.tf @@ -549,7 +549,7 @@ resource "google_container_node_pool" "pools" { local.service_account, ) preemptible = lookup(each.value, "preemptible", false) - spot = lookup(each.value, "spot", false) + spot = lookup(each.value, "spot", false) oauth_scopes = concat( local.node_pools_oauth_scopes["all"], diff --git a/modules/beta-private-cluster/README.md b/modules/beta-private-cluster/README.md index 4cacc99790..bab4d35316 100644 --- a/modules/beta-private-cluster/README.md +++ b/modules/beta-private-cluster/README.md @@ -63,6 +63,7 @@ module "gke" { min_count = 1 max_count = 100 local_ssd_count = 0 + spot = false local_ssd_ephemeral_count = 0 disk_size_gb = 100 disk_type = "pd-standard" @@ -71,7 +72,6 @@ module "gke" { auto_upgrade = true service_account = "project-service-account@.iam.gserviceaccount.com" preemptible = false - spot = false initial_node_count = 80 }, ] diff --git a/modules/beta-private-cluster/cluster.tf b/modules/beta-private-cluster/cluster.tf index a524dd9257..0dacff4faf 100644 --- a/modules/beta-private-cluster/cluster.tf +++ b/modules/beta-private-cluster/cluster.tf @@ -463,7 +463,7 @@ resource "google_container_node_pool" "pools" { local.service_account, ) preemptible = lookup(each.value, "preemptible", false) - spot = lookup(each.value, "spot", false) + spot = lookup(each.value, "spot", false) oauth_scopes = concat( local.node_pools_oauth_scopes["all"], diff --git a/modules/beta-public-cluster-update-variant/README.md b/modules/beta-public-cluster-update-variant/README.md index d4efd1bc11..709c745454 100644 --- a/modules/beta-public-cluster-update-variant/README.md +++ b/modules/beta-public-cluster-update-variant/README.md @@ -79,6 +79,7 @@ module "gke" { min_count = 1 max_count = 100 local_ssd_count = 0 + spot = false local_ssd_ephemeral_count = 0 disk_size_gb = 100 disk_type = "pd-standard" @@ -87,7 +88,6 @@ module "gke" { auto_upgrade = true service_account = "project-service-account@.iam.gserviceaccount.com" preemptible = false - spot = false initial_node_count = 80 }, ] diff --git a/modules/beta-public-cluster-update-variant/cluster.tf b/modules/beta-public-cluster-update-variant/cluster.tf index 784f6c9ea1..cf26ad58cf 100644 --- a/modules/beta-public-cluster-update-variant/cluster.tf +++ b/modules/beta-public-cluster-update-variant/cluster.tf @@ -530,7 +530,7 @@ resource "google_container_node_pool" "pools" { local.service_account, ) preemptible = lookup(each.value, "preemptible", false) - spot = lookup(each.value, "spot", false) + spot = lookup(each.value, "spot", false) oauth_scopes = concat( local.node_pools_oauth_scopes["all"], diff --git a/modules/beta-public-cluster/README.md b/modules/beta-public-cluster/README.md index 2967854015..400fb78462 100644 --- a/modules/beta-public-cluster/README.md +++ b/modules/beta-public-cluster/README.md @@ -57,6 +57,7 @@ module "gke" { min_count = 1 max_count = 100 local_ssd_count = 0 + spot = false local_ssd_ephemeral_count = 0 disk_size_gb = 100 disk_type = "pd-standard" @@ -65,7 +66,6 @@ module "gke" { auto_upgrade = true service_account = "project-service-account@.iam.gserviceaccount.com" preemptible = false - spot = false initial_node_count = 80 }, ] diff --git a/modules/beta-public-cluster/cluster.tf b/modules/beta-public-cluster/cluster.tf index 2415e342e8..3cef8934a6 100644 --- a/modules/beta-public-cluster/cluster.tf +++ b/modules/beta-public-cluster/cluster.tf @@ -444,7 +444,7 @@ resource "google_container_node_pool" "pools" { local.service_account, ) preemptible = lookup(each.value, "preemptible", false) - spot = lookup(each.value, "spot", false) + spot = lookup(each.value, "spot", false) oauth_scopes = concat( local.node_pools_oauth_scopes["all"], From e8b5bd4ece361dac968ad71a18441dc7b2b26bb2 Mon Sep 17 00:00:00 2001 From: Adrian Chifor Date: Tue, 25 Jan 2022 11:08:38 +0000 Subject: [PATCH 3/6] Pin min beta version --- autogen/main/versions.tf.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen/main/versions.tf.tmpl b/autogen/main/versions.tf.tmpl index 5f9fca7916..bd28fb0551 100644 --- a/autogen/main/versions.tf.tmpl +++ b/autogen/main/versions.tf.tmpl @@ -24,7 +24,7 @@ terraform { required_providers { google-beta = { source = "hashicorp/google-beta" - version = ">= 4.0.0, < 5.0" + version = ">= 4.3.0, < 5.0" } kubernetes = { source = "hashicorp/kubernetes" From 277cd6a527a7ca1dd9337072d08aa12c70419544 Mon Sep 17 00:00:00 2001 From: Adrian Chifor Date: Tue, 25 Jan 2022 11:12:54 +0000 Subject: [PATCH 4/6] Make build --- modules/beta-private-cluster-update-variant/versions.tf | 2 +- modules/beta-private-cluster/versions.tf | 2 +- modules/beta-public-cluster-update-variant/versions.tf | 2 +- modules/beta-public-cluster/versions.tf | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/beta-private-cluster-update-variant/versions.tf b/modules/beta-private-cluster-update-variant/versions.tf index 736164f070..571012cbdb 100644 --- a/modules/beta-private-cluster-update-variant/versions.tf +++ b/modules/beta-private-cluster-update-variant/versions.tf @@ -21,7 +21,7 @@ terraform { required_providers { google-beta = { source = "hashicorp/google-beta" - version = ">= 4.0.0, < 5.0" + version = ">= 4.3.0, < 5.0" } kubernetes = { source = "hashicorp/kubernetes" diff --git a/modules/beta-private-cluster/versions.tf b/modules/beta-private-cluster/versions.tf index 63744c1b21..e3a5c2b2ab 100644 --- a/modules/beta-private-cluster/versions.tf +++ b/modules/beta-private-cluster/versions.tf @@ -21,7 +21,7 @@ terraform { required_providers { google-beta = { source = "hashicorp/google-beta" - version = ">= 4.0.0, < 5.0" + version = ">= 4.3.0, < 5.0" } kubernetes = { source = "hashicorp/kubernetes" diff --git a/modules/beta-public-cluster-update-variant/versions.tf b/modules/beta-public-cluster-update-variant/versions.tf index 3438841319..e94090e6f9 100644 --- a/modules/beta-public-cluster-update-variant/versions.tf +++ b/modules/beta-public-cluster-update-variant/versions.tf @@ -21,7 +21,7 @@ terraform { required_providers { google-beta = { source = "hashicorp/google-beta" - version = ">= 4.0.0, < 5.0" + version = ">= 4.3.0, < 5.0" } kubernetes = { source = "hashicorp/kubernetes" diff --git a/modules/beta-public-cluster/versions.tf b/modules/beta-public-cluster/versions.tf index a7d4794323..98d8615ebf 100644 --- a/modules/beta-public-cluster/versions.tf +++ b/modules/beta-public-cluster/versions.tf @@ -21,7 +21,7 @@ terraform { required_providers { google-beta = { source = "hashicorp/google-beta" - version = ">= 4.0.0, < 5.0" + version = ">= 4.3.0, < 5.0" } kubernetes = { source = "hashicorp/kubernetes" From b4b287185ab7ea81bd609913e610cc63f31c9996 Mon Sep 17 00:00:00 2001 From: Adrian Chifor Date: Tue, 25 Jan 2022 11:28:40 +0000 Subject: [PATCH 5/6] Update min test beta version --- test/setup/versions.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/setup/versions.tf b/test/setup/versions.tf index c010643e9d..4da100cdb5 100644 --- a/test/setup/versions.tf +++ b/test/setup/versions.tf @@ -23,7 +23,7 @@ terraform { } google-beta = { source = "hashicorp/google-beta" - version = "4.1.0" + version = "4.3.0" } random = { source = "hashicorp/random" From a3e915e7d20a45743c50e0bb86e0a3c6338ea6b2 Mon Sep 17 00:00:00 2001 From: Adrian Chifor Date: Wed, 26 Jan 2022 21:50:45 +0000 Subject: [PATCH 6/6] Note on v18 upgrade --- docs/upgrading_to_v18.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrading_to_v18.0.md b/docs/upgrading_to_v18.0.md index 7f503017a4..01ea50c116 100644 --- a/docs/upgrading_to_v18.0.md +++ b/docs/upgrading_to_v18.0.md @@ -17,7 +17,7 @@ terraform { google-beta = { source = "hashicorp/google-beta" - version = "~> 3.0" -+ version = "~> 4.0" ++ version = "~> 4.3" } }