Skip to content

Commit e4abe78

Browse files
Dev25morgante
authored andcommitted
feat: Enable Surge Upgrades by specifying max_surge and max_unavailable (Beta) (#394)
BREAKING CHANGE: beta clusters now have surge upgrades turned on by default. This behavior can be tuned using the max_surge and max_unavailable inputs.
1 parent 7d0c9aa commit e4abe78

File tree

11 files changed

+33
-0
lines changed

11 files changed

+33
-0
lines changed

autogen/main/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ The node_pools variable takes the following parameters:
189189
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
190190
{% if beta_cluster %}
191191
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
192+
| 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 |
193+
| 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 |
192194
{% endif %}
193195
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
194196
| name | The name of the node pool | | Required |

autogen/main/cluster.tf.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,13 @@ resource "google_container_node_pool" "pools" {
382382
auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade)
383383
}
384384

385+
{% if beta_cluster %}
386+
upgrade_settings {
387+
max_surge = lookup(each.value, "max_surge", 1)
388+
max_unavailable = lookup(each.value, "max_unavailable", 0)
389+
}
390+
{% endif %}
391+
385392
node_config {
386393
image_type = lookup(each.value, "image_type", "COS")
387394
machine_type = lookup(each.value, "machine_type", "n1-standard-2")

cluster.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ resource "google_container_node_pool" "pools" {
158158
auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade)
159159
}
160160

161+
161162
node_config {
162163
image_type = lookup(each.value, "image_type", "COS")
163164
machine_type = lookup(each.value, "machine_type", "n1-standard-2")

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ The node_pools variable takes the following parameters:
276276
| machine_type | The name of a Google Compute Engine machine type | n1-standard-2 | Optional |
277277
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
278278
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
279+
| 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 |
280+
| 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 |
279281
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
280282
| name | The name of the node pool | | Required |
281283
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusers | | Required |

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ resource "google_container_node_pool" "pools" {
346346
auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade)
347347
}
348348

349+
upgrade_settings {
350+
max_surge = lookup(each.value, "max_surge", 1)
351+
max_unavailable = lookup(each.value, "max_unavailable", 0)
352+
}
353+
349354
node_config {
350355
image_type = lookup(each.value, "image_type", "COS")
351356
machine_type = lookup(each.value, "machine_type", "n1-standard-2")

modules/beta-private-cluster/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ The node_pools variable takes the following parameters:
254254
| machine_type | The name of a Google Compute Engine machine type | n1-standard-2 | Optional |
255255
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
256256
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
257+
| 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 |
258+
| 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 |
257259
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
258260
| name | The name of the node pool | | Required |
259261
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusers | | Required |

modules/beta-private-cluster/cluster.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ resource "google_container_node_pool" "pools" {
274274
auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade)
275275
}
276276

277+
upgrade_settings {
278+
max_surge = lookup(each.value, "max_surge", 1)
279+
max_unavailable = lookup(each.value, "max_unavailable", 0)
280+
}
281+
277282
node_config {
278283
image_type = lookup(each.value, "image_type", "COS")
279284
machine_type = lookup(each.value, "machine_type", "n1-standard-2")

modules/beta-public-cluster/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ The node_pools variable takes the following parameters:
232232
| machine_type | The name of a Google Compute Engine machine type | n1-standard-2 | Optional |
233233
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional |
234234
| max_pods_per_node | The maximum number of pods per node in this cluster | null | Optional |
235+
| 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 |
236+
| 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 |
235237
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
236238
| name | The name of the node pool | | Required |
237239
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusers | | Required |

modules/beta-public-cluster/cluster.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ resource "google_container_node_pool" "pools" {
261261
auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade)
262262
}
263263

264+
upgrade_settings {
265+
max_surge = lookup(each.value, "max_surge", 1)
266+
max_unavailable = lookup(each.value, "max_unavailable", 0)
267+
}
268+
264269
node_config {
265270
image_type = lookup(each.value, "image_type", "COS")
266271
machine_type = lookup(each.value, "machine_type", "n1-standard-2")

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ resource "google_container_node_pool" "pools" {
243243
auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade)
244244
}
245245

246+
246247
node_config {
247248
image_type = lookup(each.value, "image_type", "COS")
248249
machine_type = lookup(each.value, "machine_type", "n1-standard-2")

0 commit comments

Comments
 (0)