From 11bae6791b07efcce29a0227e0b8b4d6c7070971 Mon Sep 17 00:00:00 2001 From: Yury Akudovich Date: Fri, 17 May 2024 18:58:37 +0200 Subject: [PATCH] feat: Add secondary_boot_disks to node_pool configuration. (#1946) --- README.md | 1 + autogen/main/README.md | 1 + autogen/main/cluster.tf.tmpl | 9 +++++++++ cluster.tf | 18 ++++++++++++++++++ .../README.md | 1 + .../cluster.tf | 18 ++++++++++++++++++ modules/beta-private-cluster/README.md | 1 + modules/beta-private-cluster/cluster.tf | 18 ++++++++++++++++++ .../README.md | 1 + .../cluster.tf | 18 ++++++++++++++++++ modules/beta-public-cluster/README.md | 1 + modules/beta-public-cluster/cluster.tf | 18 ++++++++++++++++++ .../private-cluster-update-variant/README.md | 1 + .../private-cluster-update-variant/cluster.tf | 18 ++++++++++++++++++ modules/private-cluster/README.md | 1 + modules/private-cluster/cluster.tf | 18 ++++++++++++++++++ 16 files changed, 143 insertions(+) diff --git a/README.md b/README.md index 31583b573..24d24fc81 100644 --- a/README.md +++ b/README.md @@ -325,6 +325,7 @@ The node_pools variable takes the following parameters: | value | The value for the taint | | Required | | version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional | | location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional | +| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see [documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#nested_secondary_boot_disks). `gcfs_config` must be `enabled=true` for this feature to work. | | Optional | ## windows_node_pools variable The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created. diff --git a/autogen/main/README.md b/autogen/main/README.md index d32baae8a..15dddf735 100644 --- a/autogen/main/README.md +++ b/autogen/main/README.md @@ -250,6 +250,7 @@ The node_pools variable takes the following parameters: | value | The value for the taint | | Required | | version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional | | location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional | +| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see [documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#nested_secondary_boot_disks). `gcfs_config` must be `enabled=true` for this feature to work. | | Optional | ## windows_node_pools variable The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created. diff --git a/autogen/main/cluster.tf.tmpl b/autogen/main/cluster.tf.tmpl index c6028215d..aeaa4266d 100644 --- a/autogen/main/cluster.tf.tmpl +++ b/autogen/main/cluster.tf.tmpl @@ -864,6 +864,15 @@ resource "google_container_node_pool" "windows_pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", diff --git a/cluster.tf b/cluster.tf index c67758d5e..228a1d641 100644 --- a/cluster.tf +++ b/cluster.tf @@ -582,6 +582,15 @@ resource "google_container_node_pool" "pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", @@ -798,6 +807,15 @@ resource "google_container_node_pool" "windows_pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", diff --git a/modules/beta-private-cluster-update-variant/README.md b/modules/beta-private-cluster-update-variant/README.md index 556d7c4d6..5f25cf811 100644 --- a/modules/beta-private-cluster-update-variant/README.md +++ b/modules/beta-private-cluster-update-variant/README.md @@ -391,6 +391,7 @@ The node_pools variable takes the following parameters: | value | The value for the taint | | Required | | version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional | | location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional | +| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see [documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#nested_secondary_boot_disks). `gcfs_config` must be `enabled=true` for this feature to work. | | Optional | ## windows_node_pools variable The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created. diff --git a/modules/beta-private-cluster-update-variant/cluster.tf b/modules/beta-private-cluster-update-variant/cluster.tf index fc9b5085b..0f0be2326 100644 --- a/modules/beta-private-cluster-update-variant/cluster.tf +++ b/modules/beta-private-cluster-update-variant/cluster.tf @@ -748,6 +748,15 @@ resource "google_container_node_pool" "pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", @@ -990,6 +999,15 @@ resource "google_container_node_pool" "windows_pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", diff --git a/modules/beta-private-cluster/README.md b/modules/beta-private-cluster/README.md index b7048076a..6cbf21810 100644 --- a/modules/beta-private-cluster/README.md +++ b/modules/beta-private-cluster/README.md @@ -369,6 +369,7 @@ The node_pools variable takes the following parameters: | value | The value for the taint | | Required | | version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional | | location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional | +| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see [documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#nested_secondary_boot_disks). `gcfs_config` must be `enabled=true` for this feature to work. | | Optional | ## windows_node_pools variable The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created. diff --git a/modules/beta-private-cluster/cluster.tf b/modules/beta-private-cluster/cluster.tf index 46bbae50c..4c7d34592 100644 --- a/modules/beta-private-cluster/cluster.tf +++ b/modules/beta-private-cluster/cluster.tf @@ -673,6 +673,15 @@ resource "google_container_node_pool" "pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", @@ -914,6 +923,15 @@ resource "google_container_node_pool" "windows_pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", diff --git a/modules/beta-public-cluster-update-variant/README.md b/modules/beta-public-cluster-update-variant/README.md index aa9f18bdc..4b26ef1b3 100644 --- a/modules/beta-public-cluster-update-variant/README.md +++ b/modules/beta-public-cluster-update-variant/README.md @@ -379,6 +379,7 @@ The node_pools variable takes the following parameters: | value | The value for the taint | | Required | | version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional | | location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional | +| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see [documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#nested_secondary_boot_disks). `gcfs_config` must be `enabled=true` for this feature to work. | | Optional | ## windows_node_pools variable The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created. diff --git a/modules/beta-public-cluster-update-variant/cluster.tf b/modules/beta-public-cluster-update-variant/cluster.tf index 2845da381..22a144fdd 100644 --- a/modules/beta-public-cluster-update-variant/cluster.tf +++ b/modules/beta-public-cluster-update-variant/cluster.tf @@ -729,6 +729,15 @@ resource "google_container_node_pool" "pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", @@ -971,6 +980,15 @@ resource "google_container_node_pool" "windows_pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", diff --git a/modules/beta-public-cluster/README.md b/modules/beta-public-cluster/README.md index baaf2a4fa..d7cfb53ae 100644 --- a/modules/beta-public-cluster/README.md +++ b/modules/beta-public-cluster/README.md @@ -357,6 +357,7 @@ The node_pools variable takes the following parameters: | value | The value for the taint | | Required | | version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional | | location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional | +| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see [documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#nested_secondary_boot_disks). `gcfs_config` must be `enabled=true` for this feature to work. | | Optional | ## windows_node_pools variable The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created. diff --git a/modules/beta-public-cluster/cluster.tf b/modules/beta-public-cluster/cluster.tf index 233e59765..6944647cf 100644 --- a/modules/beta-public-cluster/cluster.tf +++ b/modules/beta-public-cluster/cluster.tf @@ -654,6 +654,15 @@ resource "google_container_node_pool" "pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", @@ -895,6 +904,15 @@ resource "google_container_node_pool" "windows_pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", diff --git a/modules/private-cluster-update-variant/README.md b/modules/private-cluster-update-variant/README.md index 30dc76161..2d885826c 100644 --- a/modules/private-cluster-update-variant/README.md +++ b/modules/private-cluster-update-variant/README.md @@ -360,6 +360,7 @@ The node_pools variable takes the following parameters: | value | The value for the taint | | Required | | version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional | | location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional | +| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see [documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#nested_secondary_boot_disks). `gcfs_config` must be `enabled=true` for this feature to work. | | Optional | ## windows_node_pools variable The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created. diff --git a/modules/private-cluster-update-variant/cluster.tf b/modules/private-cluster-update-variant/cluster.tf index a1b98e44a..8a1c33ab9 100644 --- a/modules/private-cluster-update-variant/cluster.tf +++ b/modules/private-cluster-update-variant/cluster.tf @@ -676,6 +676,15 @@ resource "google_container_node_pool" "pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", @@ -893,6 +902,15 @@ resource "google_container_node_pool" "windows_pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", diff --git a/modules/private-cluster/README.md b/modules/private-cluster/README.md index 7ee544dee..68daa2241 100644 --- a/modules/private-cluster/README.md +++ b/modules/private-cluster/README.md @@ -338,6 +338,7 @@ The node_pools variable takes the following parameters: | value | The value for the taint | | Required | | version | The Kubernetes version for the nodes in this pool. Should only be set if auto_upgrade is false | " " | Optional | | location_policy | [Location policy](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#location_policy) specifies the algorithm used when scaling-up the node pool. Location policy is supported only in 1.24.1+ clusters. | " " | Optional | +| secondary_boot_disk | Image of a secondary boot disk to preload container images and data on new nodes. For detail see [documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#nested_secondary_boot_disks). `gcfs_config` must be `enabled=true` for this feature to work. | | Optional | ## windows_node_pools variable The windows_node_pools variable takes the same parameters as [node_pools](#node\_pools-variable) but is reserved for provisioning Windows based node pools only. This variable is introduced to satisfy a [specific requirement](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#create_a_cluster_and_node_pools) for the presence of at least one linux based node pool in the cluster before a windows based node pool can be created. diff --git a/modules/private-cluster/cluster.tf b/modules/private-cluster/cluster.tf index 9dcb9055e..37e445697 100644 --- a/modules/private-cluster/cluster.tf +++ b/modules/private-cluster/cluster.tf @@ -601,6 +601,15 @@ resource "google_container_node_pool" "pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account", @@ -817,6 +826,15 @@ resource "google_container_node_pool" "windows_pools" { } } + # Supports a single secondary boot disk because `map(any)` must have the same values type. + dynamic "secondary_boot_disks" { + for_each = lookup(each.value, "secondary_boot_disk", "") != "" ? [each.value.secondary_boot_disk] : [] + content { + disk_image = secondary_boot_disks.value + mode = "CONTAINER_IMAGE_CACHE" + } + } + service_account = lookup( each.value, "service_account",