From e573cedee0a82517410f9d607ce69be7189124ca Mon Sep 17 00:00:00 2001 From: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> Date: Wed, 22 May 2024 20:42:04 +0200 Subject: [PATCH] feat: Add threads_per_core setting for node config in node pools (#1942) --- README.md | 1 + autogen/main/README.md | 1 + autogen/main/cluster.tf.tmpl | 7 +++++++ cluster.tf | 14 ++++++++++++++ .../beta-private-cluster-update-variant/README.md | 1 + .../beta-private-cluster-update-variant/cluster.tf | 14 ++++++++++++++ modules/beta-private-cluster/README.md | 1 + modules/beta-private-cluster/cluster.tf | 14 ++++++++++++++ .../beta-public-cluster-update-variant/README.md | 1 + .../beta-public-cluster-update-variant/cluster.tf | 14 ++++++++++++++ modules/beta-public-cluster/README.md | 1 + modules/beta-public-cluster/cluster.tf | 14 ++++++++++++++ modules/private-cluster-update-variant/README.md | 1 + modules/private-cluster-update-variant/cluster.tf | 14 ++++++++++++++ modules/private-cluster/README.md | 1 + modules/private-cluster/cluster.tf | 14 ++++++++++++++ 16 files changed, 113 insertions(+) diff --git a/README.md b/README.md index 9296f278c..c354cd843 100644 --- a/README.md +++ b/README.md @@ -308,6 +308,7 @@ The node_pools variable takes the following parameters: | total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional | | max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional | | strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: `SURGE` or `BLUE_GREEN` | "SURGE" | Optional | +| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional | | max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with `SURGE` strategy. | 1 | Optional | | max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with `SURGE` strategy. | 0 | Optional | | node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with `BLUE_GREEN` strategy. | "3600s" | Optional | diff --git a/autogen/main/README.md b/autogen/main/README.md index 49827285e..5801d04b4 100644 --- a/autogen/main/README.md +++ b/autogen/main/README.md @@ -223,6 +223,7 @@ The node_pools variable takes the following parameters: | total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional | | max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional | | strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: `SURGE` or `BLUE_GREEN` | "SURGE" | Optional | +| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional | | max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with `SURGE` strategy. | 1 | Optional | | max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with `SURGE` strategy. | 0 | Optional | | node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with `BLUE_GREEN` strategy. | "3600s" | Optional | diff --git a/autogen/main/cluster.tf.tmpl b/autogen/main/cluster.tf.tmpl index 96356c808..49a2508cc 100644 --- a/autogen/main/cluster.tf.tmpl +++ b/autogen/main/cluster.tf.tmpl @@ -930,6 +930,13 @@ resource "google_container_node_pool" "windows_pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config diff --git a/cluster.tf b/cluster.tf index d4c17bcec..32f9f29d7 100644 --- a/cluster.tf +++ b/cluster.tf @@ -647,6 +647,13 @@ resource "google_container_node_pool" "pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config @@ -878,6 +885,13 @@ resource "google_container_node_pool" "windows_pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config diff --git a/modules/beta-private-cluster-update-variant/README.md b/modules/beta-private-cluster-update-variant/README.md index aa24ab95c..883af3419 100644 --- a/modules/beta-private-cluster-update-variant/README.md +++ b/modules/beta-private-cluster-update-variant/README.md @@ -371,6 +371,7 @@ The node_pools variable takes the following parameters: | total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional | | max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional | | strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: `SURGE` or `BLUE_GREEN` | "SURGE" | Optional | +| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional | | max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with `SURGE` strategy. | 1 | Optional | | max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with `SURGE` strategy. | 0 | Optional | | node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with `BLUE_GREEN` strategy. | "3600s" | Optional | diff --git a/modules/beta-private-cluster-update-variant/cluster.tf b/modules/beta-private-cluster-update-variant/cluster.tf index fdb6f891d..9a0b42108 100644 --- a/modules/beta-private-cluster-update-variant/cluster.tf +++ b/modules/beta-private-cluster-update-variant/cluster.tf @@ -814,6 +814,13 @@ resource "google_container_node_pool" "pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config @@ -1071,6 +1078,13 @@ resource "google_container_node_pool" "windows_pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config diff --git a/modules/beta-private-cluster/README.md b/modules/beta-private-cluster/README.md index 91b95efbb..0f06cabef 100644 --- a/modules/beta-private-cluster/README.md +++ b/modules/beta-private-cluster/README.md @@ -349,6 +349,7 @@ The node_pools variable takes the following parameters: | total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional | | max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional | | strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: `SURGE` or `BLUE_GREEN` | "SURGE" | Optional | +| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional | | max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with `SURGE` strategy. | 1 | Optional | | max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with `SURGE` strategy. | 0 | Optional | | node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with `BLUE_GREEN` strategy. | "3600s" | Optional | diff --git a/modules/beta-private-cluster/cluster.tf b/modules/beta-private-cluster/cluster.tf index 742ecaef3..135659eb5 100644 --- a/modules/beta-private-cluster/cluster.tf +++ b/modules/beta-private-cluster/cluster.tf @@ -738,6 +738,13 @@ resource "google_container_node_pool" "pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config @@ -994,6 +1001,13 @@ resource "google_container_node_pool" "windows_pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config diff --git a/modules/beta-public-cluster-update-variant/README.md b/modules/beta-public-cluster-update-variant/README.md index 9ccec076a..12dacc212 100644 --- a/modules/beta-public-cluster-update-variant/README.md +++ b/modules/beta-public-cluster-update-variant/README.md @@ -358,6 +358,7 @@ The node_pools variable takes the following parameters: | total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional | | max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional | | strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: `SURGE` or `BLUE_GREEN` | "SURGE" | Optional | +| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional | | max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with `SURGE` strategy. | 1 | Optional | | max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with `SURGE` strategy. | 0 | Optional | | node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with `BLUE_GREEN` strategy. | "3600s" | Optional | diff --git a/modules/beta-public-cluster-update-variant/cluster.tf b/modules/beta-public-cluster-update-variant/cluster.tf index 2d0f4ff8e..9f2e50b48 100644 --- a/modules/beta-public-cluster-update-variant/cluster.tf +++ b/modules/beta-public-cluster-update-variant/cluster.tf @@ -795,6 +795,13 @@ resource "google_container_node_pool" "pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config @@ -1052,6 +1059,13 @@ resource "google_container_node_pool" "windows_pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config diff --git a/modules/beta-public-cluster/README.md b/modules/beta-public-cluster/README.md index 9f8037a19..5a5ce13de 100644 --- a/modules/beta-public-cluster/README.md +++ b/modules/beta-public-cluster/README.md @@ -336,6 +336,7 @@ The node_pools variable takes the following parameters: | total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional | | max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional | | strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: `SURGE` or `BLUE_GREEN` | "SURGE" | Optional | +| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional | | max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with `SURGE` strategy. | 1 | Optional | | max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with `SURGE` strategy. | 0 | Optional | | node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with `BLUE_GREEN` strategy. | "3600s" | Optional | diff --git a/modules/beta-public-cluster/cluster.tf b/modules/beta-public-cluster/cluster.tf index fcbac0cac..12db7772e 100644 --- a/modules/beta-public-cluster/cluster.tf +++ b/modules/beta-public-cluster/cluster.tf @@ -719,6 +719,13 @@ resource "google_container_node_pool" "pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config @@ -975,6 +982,13 @@ resource "google_container_node_pool" "windows_pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config diff --git a/modules/private-cluster-update-variant/README.md b/modules/private-cluster-update-variant/README.md index 267ab2b50..b20d8da1a 100644 --- a/modules/private-cluster-update-variant/README.md +++ b/modules/private-cluster-update-variant/README.md @@ -343,6 +343,7 @@ The node_pools variable takes the following parameters: | total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional | | max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional | | strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: `SURGE` or `BLUE_GREEN` | "SURGE" | Optional | +| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional | | max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with `SURGE` strategy. | 1 | Optional | | max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with `SURGE` strategy. | 0 | Optional | | node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with `BLUE_GREEN` strategy. | "3600s" | Optional | diff --git a/modules/private-cluster-update-variant/cluster.tf b/modules/private-cluster-update-variant/cluster.tf index d48a810a0..2dcbfe095 100644 --- a/modules/private-cluster-update-variant/cluster.tf +++ b/modules/private-cluster-update-variant/cluster.tf @@ -742,6 +742,13 @@ resource "google_container_node_pool" "pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config @@ -974,6 +981,13 @@ resource "google_container_node_pool" "windows_pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config diff --git a/modules/private-cluster/README.md b/modules/private-cluster/README.md index dc1559b94..9d77ba0c2 100644 --- a/modules/private-cluster/README.md +++ b/modules/private-cluster/README.md @@ -321,6 +321,7 @@ The node_pools variable takes the following parameters: | total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional | | max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional | | strategy | The upgrade stragey to be used for upgrading the nodes. Valid values of state are: `SURGE` or `BLUE_GREEN` | "SURGE" | Optional | +| threads_per_core | Optional The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed | null | Optional | | max_surge | The number of additional nodes that can be added to the node pool during an upgrade. Increasing max_surge raises the number of nodes that can be upgraded simultaneously. Can be set to 0 or greater. Only works with `SURGE` strategy. | 1 | Optional | | max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. Only works with `SURGE` strategy. | 0 | Optional | | node_pool_soak_duration | Time needed after draining the entire blue pool. After this period, the blue pool will be cleaned up. By default, it is set to one hour (3600 seconds). The maximum length of the soak time is 7 days (604,800 seconds). Only works with `BLUE_GREEN` strategy. | "3600s" | Optional | diff --git a/modules/private-cluster/cluster.tf b/modules/private-cluster/cluster.tf index 335415508..34f56ffac 100644 --- a/modules/private-cluster/cluster.tf +++ b/modules/private-cluster/cluster.tf @@ -666,6 +666,13 @@ resource "google_container_node_pool" "pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config @@ -897,6 +904,13 @@ resource "google_container_node_pool" "windows_pools" { } } + dynamic "advanced_machine_features" { + for_each = lookup(each.value, "threads_per_core", 0) > 0 ? [1] : [] + content { + threads_per_core = lookup(each.value, "threads_per_core", 0) + } + } + dynamic "workload_metadata_config" { for_each = local.cluster_node_metadata_config