diff --git a/autogen/main/cluster.tf.tmpl b/autogen/main/cluster.tf.tmpl index d997ac407b..6261a06406 100644 --- a/autogen/main/cluster.tf.tmpl +++ b/autogen/main/cluster.tf.tmpl @@ -1111,6 +1111,7 @@ resource "google_container_node_pool" "windows_pools" { for_each = length(merge( local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]], + local.node_pools_cgroup_mode["all"] == "" ? {} : { cgroup = local.node_pools_cgroup_mode["all"] }, local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : {cgroup = local.node_pools_cgroup_mode[each.value["name"]]} )) != 0 ? [1] : [] @@ -1119,7 +1120,7 @@ resource "google_container_node_pool" "windows_pools" { local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]] ) - cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]] + cgroup_mode = coalesce(local.node_pools_cgroup_mode[each.value["name"]], local.node_pools_cgroup_mode["all"], null) } } {% endif %} diff --git a/autogen/main/variables_defaults.tf.tmpl b/autogen/main/variables_defaults.tf.tmpl index 8d771e2dc5..0348cc8c1f 100644 --- a/autogen/main/variables_defaults.tf.tmpl +++ b/autogen/main/variables_defaults.tf.tmpl @@ -128,14 +128,15 @@ locals { ), var.node_pools_linux_node_configs_sysctls ) - node_pools_cgroup_mode = merge( - { all = "" }, - { default-node-pool = "" }, - zipmap( - [for node_pool in var.node_pools : node_pool["name"]], - [for node_pool in var.node_pools : ""] - ), - var.node_pools_cgroup_mode + + node_pools_cgroup_mode = merge( + { all = "" }, + { default-node-pool = "" }, + zipmap( + [for node_pool in var.node_pools : node_pool["name"]], + [for node_pool in var.node_pools : ""] + ), + var.node_pools_cgroup_mode ) } {% endif %} diff --git a/cluster.tf b/cluster.tf index d53799e500..c241aef605 100644 --- a/cluster.tf +++ b/cluster.tf @@ -804,6 +804,7 @@ resource "google_container_node_pool" "pools" { for_each = length(merge( local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]], + local.node_pools_cgroup_mode["all"] == "" ? {} : { cgroup = local.node_pools_cgroup_mode["all"] }, local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] } )) != 0 ? [1] : [] @@ -812,7 +813,7 @@ resource "google_container_node_pool" "pools" { local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]] ) - cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]] + cgroup_mode = coalesce(local.node_pools_cgroup_mode[each.value["name"]], local.node_pools_cgroup_mode["all"], null) } } diff --git a/examples/node_pool/main.tf b/examples/node_pool/main.tf index 3713311de6..a15ba27e46 100644 --- a/examples/node_pool/main.tf +++ b/examples/node_pool/main.tf @@ -150,4 +150,9 @@ module "gke" { "net.core.netdev_max_backlog" = "20000" } } + + node_pools_cgroup_mode = { + all = "CGROUP_MODE_V1" + pool-01 = "CGROUP_MODE_V2" + } } diff --git a/modules/beta-private-cluster-update-variant/cluster.tf b/modules/beta-private-cluster-update-variant/cluster.tf index 3fec97d43a..f86cd27458 100644 --- a/modules/beta-private-cluster-update-variant/cluster.tf +++ b/modules/beta-private-cluster-update-variant/cluster.tf @@ -975,6 +975,7 @@ resource "google_container_node_pool" "pools" { for_each = length(merge( local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]], + local.node_pools_cgroup_mode["all"] == "" ? {} : { cgroup = local.node_pools_cgroup_mode["all"] }, local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] } )) != 0 ? [1] : [] @@ -983,7 +984,7 @@ resource "google_container_node_pool" "pools" { local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]] ) - cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]] + cgroup_mode = coalesce(local.node_pools_cgroup_mode[each.value["name"]], local.node_pools_cgroup_mode["all"], null) } } diff --git a/modules/beta-private-cluster-update-variant/variables_defaults.tf b/modules/beta-private-cluster-update-variant/variables_defaults.tf index c33f3828e7..5c7f51b42f 100644 --- a/modules/beta-private-cluster-update-variant/variables_defaults.tf +++ b/modules/beta-private-cluster-update-variant/variables_defaults.tf @@ -127,6 +127,7 @@ locals { ), var.node_pools_linux_node_configs_sysctls ) + node_pools_cgroup_mode = merge( { all = "" }, { default-node-pool = "" }, diff --git a/modules/beta-private-cluster/cluster.tf b/modules/beta-private-cluster/cluster.tf index 73d12ec042..2a2362e60d 100644 --- a/modules/beta-private-cluster/cluster.tf +++ b/modules/beta-private-cluster/cluster.tf @@ -894,6 +894,7 @@ resource "google_container_node_pool" "pools" { for_each = length(merge( local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]], + local.node_pools_cgroup_mode["all"] == "" ? {} : { cgroup = local.node_pools_cgroup_mode["all"] }, local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] } )) != 0 ? [1] : [] @@ -902,7 +903,7 @@ resource "google_container_node_pool" "pools" { local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]] ) - cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]] + cgroup_mode = coalesce(local.node_pools_cgroup_mode[each.value["name"]], local.node_pools_cgroup_mode["all"], null) } } diff --git a/modules/beta-private-cluster/variables_defaults.tf b/modules/beta-private-cluster/variables_defaults.tf index c33f3828e7..5c7f51b42f 100644 --- a/modules/beta-private-cluster/variables_defaults.tf +++ b/modules/beta-private-cluster/variables_defaults.tf @@ -127,6 +127,7 @@ locals { ), var.node_pools_linux_node_configs_sysctls ) + node_pools_cgroup_mode = merge( { all = "" }, { default-node-pool = "" }, diff --git a/modules/beta-public-cluster-update-variant/cluster.tf b/modules/beta-public-cluster-update-variant/cluster.tf index 057e419081..2fd7580755 100644 --- a/modules/beta-public-cluster-update-variant/cluster.tf +++ b/modules/beta-public-cluster-update-variant/cluster.tf @@ -945,6 +945,7 @@ resource "google_container_node_pool" "pools" { for_each = length(merge( local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]], + local.node_pools_cgroup_mode["all"] == "" ? {} : { cgroup = local.node_pools_cgroup_mode["all"] }, local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] } )) != 0 ? [1] : [] @@ -953,7 +954,7 @@ resource "google_container_node_pool" "pools" { local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]] ) - cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]] + cgroup_mode = coalesce(local.node_pools_cgroup_mode[each.value["name"]], local.node_pools_cgroup_mode["all"], null) } } diff --git a/modules/beta-public-cluster-update-variant/variables_defaults.tf b/modules/beta-public-cluster-update-variant/variables_defaults.tf index c33f3828e7..5c7f51b42f 100644 --- a/modules/beta-public-cluster-update-variant/variables_defaults.tf +++ b/modules/beta-public-cluster-update-variant/variables_defaults.tf @@ -127,6 +127,7 @@ locals { ), var.node_pools_linux_node_configs_sysctls ) + node_pools_cgroup_mode = merge( { all = "" }, { default-node-pool = "" }, diff --git a/modules/beta-public-cluster/cluster.tf b/modules/beta-public-cluster/cluster.tf index 42a350b6ba..ae1d831ccb 100644 --- a/modules/beta-public-cluster/cluster.tf +++ b/modules/beta-public-cluster/cluster.tf @@ -864,6 +864,7 @@ resource "google_container_node_pool" "pools" { for_each = length(merge( local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]], + local.node_pools_cgroup_mode["all"] == "" ? {} : { cgroup = local.node_pools_cgroup_mode["all"] }, local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] } )) != 0 ? [1] : [] @@ -872,7 +873,7 @@ resource "google_container_node_pool" "pools" { local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]] ) - cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]] + cgroup_mode = coalesce(local.node_pools_cgroup_mode[each.value["name"]], local.node_pools_cgroup_mode["all"], null) } } diff --git a/modules/beta-public-cluster/variables_defaults.tf b/modules/beta-public-cluster/variables_defaults.tf index c33f3828e7..5c7f51b42f 100644 --- a/modules/beta-public-cluster/variables_defaults.tf +++ b/modules/beta-public-cluster/variables_defaults.tf @@ -127,6 +127,7 @@ locals { ), var.node_pools_linux_node_configs_sysctls ) + node_pools_cgroup_mode = merge( { all = "" }, { default-node-pool = "" }, diff --git a/modules/private-cluster-update-variant/cluster.tf b/modules/private-cluster-update-variant/cluster.tf index fa03099a0c..104b69aed6 100644 --- a/modules/private-cluster-update-variant/cluster.tf +++ b/modules/private-cluster-update-variant/cluster.tf @@ -914,6 +914,7 @@ resource "google_container_node_pool" "pools" { for_each = length(merge( local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]], + local.node_pools_cgroup_mode["all"] == "" ? {} : { cgroup = local.node_pools_cgroup_mode["all"] }, local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] } )) != 0 ? [1] : [] @@ -922,7 +923,7 @@ resource "google_container_node_pool" "pools" { local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]] ) - cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]] + cgroup_mode = coalesce(local.node_pools_cgroup_mode[each.value["name"]], local.node_pools_cgroup_mode["all"], null) } } diff --git a/modules/private-cluster-update-variant/variables_defaults.tf b/modules/private-cluster-update-variant/variables_defaults.tf index c33f3828e7..5c7f51b42f 100644 --- a/modules/private-cluster-update-variant/variables_defaults.tf +++ b/modules/private-cluster-update-variant/variables_defaults.tf @@ -127,6 +127,7 @@ locals { ), var.node_pools_linux_node_configs_sysctls ) + node_pools_cgroup_mode = merge( { all = "" }, { default-node-pool = "" }, diff --git a/modules/private-cluster/cluster.tf b/modules/private-cluster/cluster.tf index 3ca8117ae6..c81cf14264 100644 --- a/modules/private-cluster/cluster.tf +++ b/modules/private-cluster/cluster.tf @@ -834,6 +834,7 @@ resource "google_container_node_pool" "pools" { for_each = length(merge( local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]], + local.node_pools_cgroup_mode["all"] == "" ? {} : { cgroup = local.node_pools_cgroup_mode["all"] }, local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] } )) != 0 ? [1] : [] @@ -842,7 +843,7 @@ resource "google_container_node_pool" "pools" { local.node_pools_linux_node_configs_sysctls["all"], local.node_pools_linux_node_configs_sysctls[each.value["name"]] ) - cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]] + cgroup_mode = coalesce(local.node_pools_cgroup_mode[each.value["name"]], local.node_pools_cgroup_mode["all"], null) } } diff --git a/modules/private-cluster/variables_defaults.tf b/modules/private-cluster/variables_defaults.tf index c33f3828e7..5c7f51b42f 100644 --- a/modules/private-cluster/variables_defaults.tf +++ b/modules/private-cluster/variables_defaults.tf @@ -127,6 +127,7 @@ locals { ), var.node_pools_linux_node_configs_sysctls ) + node_pools_cgroup_mode = merge( { all = "" }, { default-node-pool = "" }, diff --git a/test/integration/node_pool/testdata/TestNodePool.json b/test/integration/node_pool/testdata/TestNodePool.json index 413d0ce050..2175d01c60 100644 --- a/test/integration/node_pool/testdata/TestNodePool.json +++ b/test/integration/node_pool/testdata/TestNodePool.json @@ -270,7 +270,7 @@ "config": { "diskSizeGb": 100, "diskType": "pd-standard", - "effectiveCgroupMode": "EFFECTIVE_CGROUP_MODE_V2", + "effectiveCgroupMode": "EFFECTIVE_CGROUP_MODE_V1", "imageType": "COS_CONTAINERD", "machineType": "e2-medium", "metadata": { @@ -425,7 +425,7 @@ ], "diskSizeGb": 30, "diskType": "pd-standard", - "effectiveCgroupMode": "EFFECTIVE_CGROUP_MODE_V2", + "effectiveCgroupMode": "EFFECTIVE_CGROUP_MODE_V1", "imageType": "COS_CONTAINERD", "labels": { "all-pools-example": "true", @@ -505,7 +505,7 @@ "config": { "diskSizeGb": 100, "diskType": "pd-standard", - "effectiveCgroupMode": "EFFECTIVE_CGROUP_MODE_V2", + "effectiveCgroupMode": "EFFECTIVE_CGROUP_MODE_V1", "imageType": "COS_CONTAINERD", "kubeletConfig": { "cpuCfsQuota": true, @@ -603,7 +603,7 @@ "config": { "diskSizeGb": 100, "diskType": "pd-standard", - "effectiveCgroupMode": "EFFECTIVE_CGROUP_MODE_V2", + "effectiveCgroupMode": "EFFECTIVE_CGROUP_MODE_V1", "imageType": "COS_CONTAINERD", "labels": { "all-pools-example": "true", @@ -698,7 +698,7 @@ }, "diskSizeGb": 100, "diskType": "pd-standard", - "effectiveCgroupMode": "EFFECTIVE_CGROUP_MODE_V2", + "effectiveCgroupMode": "EFFECTIVE_CGROUP_MODE_V1", "imageType": "COS_CONTAINERD", "labels": { "all-pools-example": "true", diff --git a/variables_defaults.tf b/variables_defaults.tf index c33f3828e7..5c7f51b42f 100644 --- a/variables_defaults.tf +++ b/variables_defaults.tf @@ -127,6 +127,7 @@ locals { ), var.node_pools_linux_node_configs_sysctls ) + node_pools_cgroup_mode = merge( { all = "" }, { default-node-pool = "" },