From e6ec5de73364890fc833d12e6382787765706aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20Jab=C5=82o=C5=84ski?= <35669512+jacek-jablonski@users.noreply.github.com> Date: Thu, 5 Jun 2025 13:41:51 +0200 Subject: [PATCH] fix additional pod networks config creation in GKE node pool (#3134) * fix additional pod networks config creation * fix doc * Replicate change in gke stage --------- Co-authored-by: Julio Castillo --- fast/stages/3-gke-dev/README.md | 2 +- fast/stages/3-gke-dev/variables.tf | 2 +- modules/gke-nodepool/README.md | 7 +++++-- modules/gke-nodepool/main.tf | 2 +- modules/gke-nodepool/variables.tf | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fast/stages/3-gke-dev/README.md b/fast/stages/3-gke-dev/README.md index 820e80649..bf95e9bcf 100644 --- a/fast/stages/3-gke-dev/README.md +++ b/fast/stages/3-gke-dev/README.md @@ -239,7 +239,7 @@ Clusters can then be configured for fleet registration and one of the config man | [host_project_ids](variables-fast.tf#L52) | Shared VPC host project name => id mappings. | map(string) | | {} | 2-networking | | [iam](variables.tf#L105) | Project-level authoritative IAM bindings for users and service accounts in {ROLE => [MEMBERS]} format. | map(list(string)) | | {} | | | [iam_by_principals](variables.tf#L112) | Authoritative IAM binding in {PRINCIPAL => [ROLES]} format. Principals need to be statically defined to avoid cycle errors. Merged internally with the `iam` variable. | map(list(string)) | | {} | | -| [nodepools](variables.tf#L119) | Nodepools configuration. Refer to the gke-nodepool module for type details. | map(map(object({…}))) | | {} | | +| [nodepools](variables.tf#L119) | Nodepools configuration. Refer to the gke-nodepool module for type details. | map(map(object({…}))) | | {} | | | [stage_config](variables.tf#L168) | FAST stage configuration used to find resource ids. Must match name defined for the stage in resource management. | object({…}) | | {…} | | | [subnet_self_links](variables-fast.tf#L70) | Subnet VPC name => { name => self link } mappings. | map(map(string)) | | {} | 2-networking | | [vpc_config](variables.tf#L180) | VPC-level configuration for project and clusters. | object({…}) | | {…} | | diff --git a/fast/stages/3-gke-dev/variables.tf b/fast/stages/3-gke-dev/variables.tf index 07a1608ee..e4b841a57 100644 --- a/fast/stages/3-gke-dev/variables.tf +++ b/fast/stages/3-gke-dev/variables.tf @@ -146,7 +146,7 @@ variable "nodepools" { network = string subnetwork = string })), []) - additional_pod_network_config = optional(list(object({ + additional_pod_network_configs = optional(list(object({ subnetwork = string secondary_pod_range = string max_pods_per_node = string diff --git a/modules/gke-nodepool/README.md b/modules/gke-nodepool/README.md index 6a9f6d141..bc526d497 100644 --- a/modules/gke-nodepool/README.md +++ b/modules/gke-nodepool/README.md @@ -67,6 +67,7 @@ module "cluster-1-nodepool-1" { } # tftest modules=1 resources=2 inventory=create-sa.yaml ``` + ### Node & node pool configuration ```hcl @@ -103,6 +104,7 @@ module "cluster-1-nodepool-1" { } # tftest modules=1 resources=2 inventory=config.yaml ``` + ### GPU Node & node pool configuration ```hcl @@ -137,7 +139,8 @@ module "cluster-1-nodepool-gpu-1" { # tftest modules=1 resources=2 inventory=guest-accelerator.yaml ``` -### Dynamic Workload Scheduler (DWS) & node pool configuration +### Dynamic Workload Scheduler (DWS) & node pool configuration + This example uses Dynamic Workload Scheduler (DWS) to configure a GPU nodepool. ```hcl @@ -198,7 +201,7 @@ module "cluster-1-nodepool-dws" { | [labels](variables.tf#L41) | The resource labels to be applied each node (vm). | map(string) | | {} | | [max_pods_per_node](variables.tf#L53) | Maximum number of pods per node. | number | | null | | [name](variables.tf#L59) | Optional nodepool name. | string | | null | -| [network_config](variables.tf#L65) | Network configuration. | object({…}) | | null | +| [network_config](variables.tf#L65) | Network configuration. | object({…}) | | null | | [node_config](variables.tf#L89) | Node-level configuration. | object({…}) | | {} | | [node_count](variables.tf#L154) | Number of nodes per instance group. Initial value can only be changed by recreation, current is ignored when autoscaling is used. | object({…}) | | {…} | | [node_locations](variables.tf#L166) | Node locations. | list(string) | | null | diff --git a/modules/gke-nodepool/main.tf b/modules/gke-nodepool/main.tf index 6caaeef6b..ddd7489c8 100644 --- a/modules/gke-nodepool/main.tf +++ b/modules/gke-nodepool/main.tf @@ -132,7 +132,7 @@ resource "google_container_node_pool" "nodepool" { dynamic "additional_pod_network_configs" { for_each = try(var.network_config.additional_pod_network_configs, []) content { - subnetwork = additional_pod_network_configs.value.network + subnetwork = additional_pod_network_configs.value.subnetwork secondary_pod_range = additional_pod_network_configs.value.secondary_pod_range max_pods_per_node = additional_pod_network_configs.value.max_pods_per_node } diff --git a/modules/gke-nodepool/variables.tf b/modules/gke-nodepool/variables.tf index 951c07cbe..0c1aabbf0 100644 --- a/modules/gke-nodepool/variables.tf +++ b/modules/gke-nodepool/variables.tf @@ -75,7 +75,7 @@ variable "network_config" { network = string subnetwork = string })), []) - additional_pod_network_config = optional(list(object({ + additional_pod_network_configs = optional(list(object({ subnetwork = string secondary_pod_range = string max_pods_per_node = string