Skip to content

Commit 98e8dc3

Browse files
fix: nodepool autoscaling vars avail in GKE 1.24.1 result in conflicts. Preserve default behavior (terraform-google-modules#1562)
Co-authored-by: Eric Zhao <[email protected]>
1 parent 6853c61 commit 98e8dc3

File tree

16 files changed

+62
-46
lines changed

16 files changed

+62
-46
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,13 @@ The node_pools variable takes the following parameters:
274274
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a `hostpath` volume or a `local` PersistentVolume. | 0 | Optional |
275275
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
276276
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
277-
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
277+
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
278+
| total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional |
278279
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
279280
| 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. | 1 | Optional |
280281
| 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. | 0 | Optional |
281-
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
282+
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with total limits. | 1 | Optional |
283+
| total_min_count | Total minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with per zone limits. | null | Optional |
282284
| name | The name of the node pool | | Required |
283285
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | | Required |
284286
| 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 |

autogen/main/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,13 @@ The node_pools variable takes the following parameters:
210210
{% endif %}
211211
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
212212
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
213-
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
213+
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
214+
| total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional |
214215
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
215216
| 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. | 1 | Optional |
216217
| 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. | 0 | Optional |
217-
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
218+
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with total limits. | 1 | Optional |
219+
| total_min_count | Total minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with per zone limits. | null | Optional |
218220
| name | The name of the node pool | | Required |
219221
{% if beta_cluster %}
220222
| placement_policy | Placement type to set for nodes in a node pool. Can be set as [COMPACT](https://cloud.google.com/kubernetes-engine/docs/how-to/compact-placement#overview) if desired | Optional |

autogen/main/cluster.tf.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ resource "google_container_node_pool" "windows_pools" {
652652
dynamic "autoscaling" {
653653
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
654654
content {
655-
min_node_count = lookup(autoscaling.value, "min_count", 1)
656-
max_node_count = lookup(autoscaling.value, "max_count", 100)
655+
min_node_count = contains(keys(autoscaling.value), "total_min_count") ? null : lookup(autoscaling.value, "min_count", 1)
656+
max_node_count = contains(keys(autoscaling.value), "total_max_count") ? null : lookup(autoscaling.value, "max_count", 100)
657657
location_policy = lookup(autoscaling.value, "location_policy", null)
658658
total_min_node_count = lookup(autoscaling.value, "total_min_count", null)
659659
total_max_node_count = lookup(autoscaling.value, "total_max_count", null)

cluster.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ resource "google_container_node_pool" "pools" {
391391
dynamic "autoscaling" {
392392
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
393393
content {
394-
min_node_count = lookup(autoscaling.value, "min_count", 1)
395-
max_node_count = lookup(autoscaling.value, "max_count", 100)
394+
min_node_count = contains(keys(autoscaling.value), "total_min_count") ? null : lookup(autoscaling.value, "min_count", 1)
395+
max_node_count = contains(keys(autoscaling.value), "total_max_count") ? null : lookup(autoscaling.value, "max_count", 100)
396396
location_policy = lookup(autoscaling.value, "location_policy", null)
397397
total_min_node_count = lookup(autoscaling.value, "total_min_count", null)
398398
total_max_node_count = lookup(autoscaling.value, "total_max_count", null)
@@ -563,8 +563,8 @@ resource "google_container_node_pool" "windows_pools" {
563563
dynamic "autoscaling" {
564564
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
565565
content {
566-
min_node_count = lookup(autoscaling.value, "min_count", 1)
567-
max_node_count = lookup(autoscaling.value, "max_count", 100)
566+
min_node_count = contains(keys(autoscaling.value), "total_min_count") ? null : lookup(autoscaling.value, "min_count", 1)
567+
max_node_count = contains(keys(autoscaling.value), "total_max_count") ? null : lookup(autoscaling.value, "max_count", 100)
568568
location_policy = lookup(autoscaling.value, "location_policy", null)
569569
total_min_node_count = lookup(autoscaling.value, "total_min_count", null)
570570
total_max_node_count = lookup(autoscaling.value, "total_max_count", null)

modules/beta-private-cluster-update-variant/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,13 @@ The node_pools variable takes the following parameters:
339339
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an `emptyDir` volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. | 0 | Optional |
340340
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
341341
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
342-
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
342+
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
343+
| total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional |
343344
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
344345
| 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. | 1 | Optional |
345346
| 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. | 0 | Optional |
346-
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
347+
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with total limits. | 1 | Optional |
348+
| total_min_count | Total minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with per zone limits. | null | Optional |
347349
| name | The name of the node pool | | Required |
348350
| placement_policy | Placement type to set for nodes in a node pool. Can be set as [COMPACT](https://cloud.google.com/kubernetes-engine/docs/how-to/compact-placement#overview) if desired | Optional |
349351
| pod_range | The name of the secondary range for pod IPs. | | Optional |

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,8 @@ resource "google_container_node_pool" "pools" {
566566
dynamic "autoscaling" {
567567
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
568568
content {
569-
min_node_count = lookup(autoscaling.value, "min_count", 1)
570-
max_node_count = lookup(autoscaling.value, "max_count", 100)
569+
min_node_count = contains(keys(autoscaling.value), "total_min_count") ? null : lookup(autoscaling.value, "min_count", 1)
570+
max_node_count = contains(keys(autoscaling.value), "total_max_count") ? null : lookup(autoscaling.value, "max_count", 100)
571571
location_policy = lookup(autoscaling.value, "location_policy", null)
572572
total_min_node_count = lookup(autoscaling.value, "total_min_count", null)
573573
total_max_node_count = lookup(autoscaling.value, "total_max_count", null)
@@ -778,8 +778,8 @@ resource "google_container_node_pool" "windows_pools" {
778778
dynamic "autoscaling" {
779779
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
780780
content {
781-
min_node_count = lookup(autoscaling.value, "min_count", 1)
782-
max_node_count = lookup(autoscaling.value, "max_count", 100)
781+
min_node_count = contains(keys(autoscaling.value), "total_min_count") ? null : lookup(autoscaling.value, "min_count", 1)
782+
max_node_count = contains(keys(autoscaling.value), "total_max_count") ? null : lookup(autoscaling.value, "max_count", 100)
783783
location_policy = lookup(autoscaling.value, "location_policy", null)
784784
total_min_node_count = lookup(autoscaling.value, "total_min_count", null)
785785
total_max_node_count = lookup(autoscaling.value, "total_max_count", null)

modules/beta-private-cluster/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,13 @@ The node_pools variable takes the following parameters:
317317
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an `emptyDir` volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. | 0 | Optional |
318318
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
319319
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
320-
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
320+
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
321+
| total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional |
321322
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
322323
| 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. | 1 | Optional |
323324
| 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. | 0 | Optional |
324-
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
325+
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with total limits. | 1 | Optional |
326+
| total_min_count | Total minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with per zone limits. | null | Optional |
325327
| name | The name of the node pool | | Required |
326328
| placement_policy | Placement type to set for nodes in a node pool. Can be set as [COMPACT](https://cloud.google.com/kubernetes-engine/docs/how-to/compact-placement#overview) if desired | Optional |
327329
| pod_range | The name of the secondary range for pod IPs. | | Optional |

modules/beta-private-cluster/cluster.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,8 @@ resource "google_container_node_pool" "pools" {
472472
dynamic "autoscaling" {
473473
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
474474
content {
475-
min_node_count = lookup(autoscaling.value, "min_count", 1)
476-
max_node_count = lookup(autoscaling.value, "max_count", 100)
475+
min_node_count = contains(keys(autoscaling.value), "total_min_count") ? null : lookup(autoscaling.value, "min_count", 1)
476+
max_node_count = contains(keys(autoscaling.value), "total_max_count") ? null : lookup(autoscaling.value, "max_count", 100)
477477
location_policy = lookup(autoscaling.value, "location_policy", null)
478478
total_min_node_count = lookup(autoscaling.value, "total_min_count", null)
479479
total_max_node_count = lookup(autoscaling.value, "total_max_count", null)
@@ -683,8 +683,8 @@ resource "google_container_node_pool" "windows_pools" {
683683
dynamic "autoscaling" {
684684
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
685685
content {
686-
min_node_count = lookup(autoscaling.value, "min_count", 1)
687-
max_node_count = lookup(autoscaling.value, "max_count", 100)
686+
min_node_count = contains(keys(autoscaling.value), "total_min_count") ? null : lookup(autoscaling.value, "min_count", 1)
687+
max_node_count = contains(keys(autoscaling.value), "total_max_count") ? null : lookup(autoscaling.value, "max_count", 100)
688688
location_policy = lookup(autoscaling.value, "location_policy", null)
689689
total_min_node_count = lookup(autoscaling.value, "total_min_count", null)
690690
total_max_node_count = lookup(autoscaling.value, "total_max_count", null)

modules/beta-public-cluster-update-variant/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,13 @@ The node_pools variable takes the following parameters:
326326
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an `emptyDir` volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. | 0 | Optional |
327327
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
328328
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
329-
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
329+
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
330+
| total_max_count | Total maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with per zone limits. | null | Optional |
330331
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
331332
| 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. | 1 | Optional |
332333
| 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. | 0 | Optional |
333-
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
334+
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with total limits. | 1 | Optional |
335+
| total_min_count | Total minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true. Cannot be used with per zone limits. | null | Optional |
334336
| name | The name of the node pool | | Required |
335337
| placement_policy | Placement type to set for nodes in a node pool. Can be set as [COMPACT](https://cloud.google.com/kubernetes-engine/docs/how-to/compact-placement#overview) if desired | Optional |
336338
| pod_range | The name of the secondary range for pod IPs. | | Optional |

modules/beta-public-cluster-update-variant/cluster.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ resource "google_container_node_pool" "pools" {
547547
dynamic "autoscaling" {
548548
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
549549
content {
550-
min_node_count = lookup(autoscaling.value, "min_count", 1)
551-
max_node_count = lookup(autoscaling.value, "max_count", 100)
550+
min_node_count = contains(keys(autoscaling.value), "total_min_count") ? null : lookup(autoscaling.value, "min_count", 1)
551+
max_node_count = contains(keys(autoscaling.value), "total_max_count") ? null : lookup(autoscaling.value, "max_count", 100)
552552
location_policy = lookup(autoscaling.value, "location_policy", null)
553553
total_min_node_count = lookup(autoscaling.value, "total_min_count", null)
554554
total_max_node_count = lookup(autoscaling.value, "total_max_count", null)
@@ -758,8 +758,8 @@ resource "google_container_node_pool" "windows_pools" {
758758
dynamic "autoscaling" {
759759
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
760760
content {
761-
min_node_count = lookup(autoscaling.value, "min_count", 1)
762-
max_node_count = lookup(autoscaling.value, "max_count", 100)
761+
min_node_count = contains(keys(autoscaling.value), "total_min_count") ? null : lookup(autoscaling.value, "min_count", 1)
762+
max_node_count = contains(keys(autoscaling.value), "total_max_count") ? null : lookup(autoscaling.value, "max_count", 100)
763763
location_policy = lookup(autoscaling.value, "location_policy", null)
764764
total_min_node_count = lookup(autoscaling.value, "total_min_count", null)
765765
total_max_node_count = lookup(autoscaling.value, "total_max_count", null)

0 commit comments

Comments
 (0)