From ae0d9536e006663701202e7e18eb932a8c195dac Mon Sep 17 00:00:00 2001 From: Adrian Chifor Date: Wed, 26 Jan 2022 23:37:05 +0000 Subject: [PATCH] feat!: Add spot vm support to beta clusters (#1131) * Add spot vm support to beta clusters * Update autogen, make build * Pin min beta version * Make build * Update min test beta version * Note on v18 upgrade --- autogen/main/README.md | 2 ++ autogen/main/cluster.tf.tmpl | 6 ++++++ autogen/main/versions.tf.tmpl | 2 +- docs/upgrading_to_v18.0.md | 2 +- modules/beta-private-cluster-update-variant/README.md | 2 ++ modules/beta-private-cluster-update-variant/cluster.tf | 2 ++ modules/beta-private-cluster-update-variant/versions.tf | 2 +- modules/beta-private-cluster/README.md | 2 ++ modules/beta-private-cluster/cluster.tf | 1 + modules/beta-private-cluster/versions.tf | 2 +- modules/beta-public-cluster-update-variant/README.md | 2 ++ modules/beta-public-cluster-update-variant/cluster.tf | 2 ++ modules/beta-public-cluster-update-variant/versions.tf | 2 +- modules/beta-public-cluster/README.md | 2 ++ modules/beta-public-cluster/cluster.tf | 1 + modules/beta-public-cluster/versions.tf | 2 +- test/setup/versions.tf | 2 +- 17 files changed, 29 insertions(+), 7 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/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" 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" } } diff --git a/modules/beta-private-cluster-update-variant/README.md b/modules/beta-private-cluster-update-variant/README.md index bebc836f4b..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" @@ -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..c6a9614401 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-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/README.md b/modules/beta-private-cluster/README.md index e6c45504ed..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" @@ -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..0dacff4faf 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-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/README.md b/modules/beta-public-cluster-update-variant/README.md index afa5c27400..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" @@ -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..cf26ad58cf 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-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/README.md b/modules/beta-public-cluster/README.md index c104f36a6c..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" @@ -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..3cef8934a6 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"], 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" 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"