Skip to content

Commit

Permalink
feat!: Add spot vm support to beta clusters (terraform-google-modules…
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
adrianchifor authored Jan 26, 2022
1 parent cdd157d commit 5d71d09
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 7 deletions.
2 changes: 2 additions & 0 deletions autogen/main/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 |
Expand Down
6 changes: 6 additions & 0 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ locals {
"machine_type",
"min_cpu_platform",
"preemptible",
{% if beta_cluster %}
"spot",
{% endif %}
"service_account",
]
}
Expand Down Expand Up @@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion autogen/main/versions.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docs/upgrading_to_v18.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ terraform {
google-beta = {
source = "hashicorp/google-beta"
- version = "~> 3.0"
+ version = "~> 4.0"
+ version = "~> 4.3"
}

}
Expand Down
2 changes: 2 additions & 0 deletions modules/beta-private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 |
Expand Down
2 changes: 2 additions & 0 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ locals {
"machine_type",
"min_cpu_platform",
"preemptible",
"spot",
"service_account",
]
}
Expand Down Expand Up @@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster-update-variant/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 |
Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions modules/beta-public-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 |
Expand Down
2 changes: 2 additions & 0 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ locals {
"machine_type",
"min_cpu_platform",
"preemptible",
"spot",
"service_account",
]
}
Expand Down Expand Up @@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-public-cluster-update-variant/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions modules/beta-public-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 |
Expand Down
1 change: 1 addition & 0 deletions modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-public-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/setup/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ terraform {
}
google-beta = {
source = "hashicorp/google-beta"
version = "4.1.0"
version = "4.3.0"
}
random = {
source = "hashicorp/random"
Expand Down

0 comments on commit 5d71d09

Please sign in to comment.