From e4abe78279ef100aeb6e4ddc0bde58cabc90acc0 Mon Sep 17 00:00:00 2001 From: Devan Patel Date: Thu, 23 Jan 2020 15:42:16 +0000 Subject: [PATCH] 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. --- autogen/main/README.md | 2 ++ autogen/main/cluster.tf.tmpl | 7 +++++++ cluster.tf | 1 + modules/beta-private-cluster-update-variant/README.md | 2 ++ modules/beta-private-cluster-update-variant/cluster.tf | 5 +++++ modules/beta-private-cluster/README.md | 2 ++ modules/beta-private-cluster/cluster.tf | 5 +++++ modules/beta-public-cluster/README.md | 2 ++ modules/beta-public-cluster/cluster.tf | 5 +++++ modules/private-cluster-update-variant/cluster.tf | 1 + modules/private-cluster/cluster.tf | 1 + 11 files changed, 33 insertions(+) diff --git a/autogen/main/README.md b/autogen/main/README.md index e7e8dcc15..abe1bb2af 100644 --- a/autogen/main/README.md +++ b/autogen/main/README.md @@ -189,6 +189,8 @@ The node_pools variable takes the following parameters: | max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional | {% if beta_cluster %} | max_pods_per_node | The maximum number of pods per node in this cluster | 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. | 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. | 0 | Optional | {% endif %} | min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional | | name | The name of the node pool | | Required | diff --git a/autogen/main/cluster.tf.tmpl b/autogen/main/cluster.tf.tmpl index c8fb7a88a..0afbf42a4 100644 --- a/autogen/main/cluster.tf.tmpl +++ b/autogen/main/cluster.tf.tmpl @@ -382,6 +382,13 @@ resource "google_container_node_pool" "pools" { auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade) } + {% if beta_cluster %} + upgrade_settings { + max_surge = lookup(each.value, "max_surge", 1) + max_unavailable = lookup(each.value, "max_unavailable", 0) + } + {% endif %} + node_config { image_type = lookup(each.value, "image_type", "COS") machine_type = lookup(each.value, "machine_type", "n1-standard-2") diff --git a/cluster.tf b/cluster.tf index 5a5734033..b56acd0f7 100644 --- a/cluster.tf +++ b/cluster.tf @@ -158,6 +158,7 @@ resource "google_container_node_pool" "pools" { auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade) } + node_config { image_type = lookup(each.value, "image_type", "COS") machine_type = lookup(each.value, "machine_type", "n1-standard-2") diff --git a/modules/beta-private-cluster-update-variant/README.md b/modules/beta-private-cluster-update-variant/README.md index 2b6a0b69b..b64a31c14 100644 --- a/modules/beta-private-cluster-update-variant/README.md +++ b/modules/beta-private-cluster-update-variant/README.md @@ -276,6 +276,8 @@ The node_pools variable takes the following parameters: | machine_type | The name of a Google Compute Engine machine type | n1-standard-2 | Optional | | max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional | | max_pods_per_node | The maximum number of pods per node in this cluster | 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. | 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. | 0 | Optional | | min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional | | name | The name of the node pool | | Required | | node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusers | | Required | diff --git a/modules/beta-private-cluster-update-variant/cluster.tf b/modules/beta-private-cluster-update-variant/cluster.tf index c7c6fa55f..4f6d2865d 100644 --- a/modules/beta-private-cluster-update-variant/cluster.tf +++ b/modules/beta-private-cluster-update-variant/cluster.tf @@ -346,6 +346,11 @@ resource "google_container_node_pool" "pools" { auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade) } + upgrade_settings { + max_surge = lookup(each.value, "max_surge", 1) + max_unavailable = lookup(each.value, "max_unavailable", 0) + } + node_config { image_type = lookup(each.value, "image_type", "COS") machine_type = lookup(each.value, "machine_type", "n1-standard-2") diff --git a/modules/beta-private-cluster/README.md b/modules/beta-private-cluster/README.md index 608ecaaaa..65cf7d581 100644 --- a/modules/beta-private-cluster/README.md +++ b/modules/beta-private-cluster/README.md @@ -254,6 +254,8 @@ The node_pools variable takes the following parameters: | machine_type | The name of a Google Compute Engine machine type | n1-standard-2 | Optional | | max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional | | max_pods_per_node | The maximum number of pods per node in this cluster | 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. | 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. | 0 | Optional | | min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional | | name | The name of the node pool | | Required | | node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusers | | Required | diff --git a/modules/beta-private-cluster/cluster.tf b/modules/beta-private-cluster/cluster.tf index 90fd8ad8b..33b25e65c 100644 --- a/modules/beta-private-cluster/cluster.tf +++ b/modules/beta-private-cluster/cluster.tf @@ -274,6 +274,11 @@ resource "google_container_node_pool" "pools" { auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade) } + upgrade_settings { + max_surge = lookup(each.value, "max_surge", 1) + max_unavailable = lookup(each.value, "max_unavailable", 0) + } + node_config { image_type = lookup(each.value, "image_type", "COS") machine_type = lookup(each.value, "machine_type", "n1-standard-2") diff --git a/modules/beta-public-cluster/README.md b/modules/beta-public-cluster/README.md index baa07bf59..32ef7ce6c 100644 --- a/modules/beta-public-cluster/README.md +++ b/modules/beta-public-cluster/README.md @@ -232,6 +232,8 @@ The node_pools variable takes the following parameters: | machine_type | The name of a Google Compute Engine machine type | n1-standard-2 | Optional | | max_count | Maximum number of nodes in the NodePool. Must be >= min_count | 100 | Optional | | max_pods_per_node | The maximum number of pods per node in this cluster | 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. | 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. | 0 | Optional | | min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional | | name | The name of the node pool | | Required | | node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusers | | Required | diff --git a/modules/beta-public-cluster/cluster.tf b/modules/beta-public-cluster/cluster.tf index 708f9325d..1b995231f 100644 --- a/modules/beta-public-cluster/cluster.tf +++ b/modules/beta-public-cluster/cluster.tf @@ -261,6 +261,11 @@ resource "google_container_node_pool" "pools" { auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade) } + upgrade_settings { + max_surge = lookup(each.value, "max_surge", 1) + max_unavailable = lookup(each.value, "max_unavailable", 0) + } + node_config { image_type = lookup(each.value, "image_type", "COS") machine_type = lookup(each.value, "machine_type", "n1-standard-2") diff --git a/modules/private-cluster-update-variant/cluster.tf b/modules/private-cluster-update-variant/cluster.tf index 7bf369be8..b0a3c1f2a 100644 --- a/modules/private-cluster-update-variant/cluster.tf +++ b/modules/private-cluster-update-variant/cluster.tf @@ -243,6 +243,7 @@ resource "google_container_node_pool" "pools" { auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade) } + node_config { image_type = lookup(each.value, "image_type", "COS") machine_type = lookup(each.value, "machine_type", "n1-standard-2") diff --git a/modules/private-cluster/cluster.tf b/modules/private-cluster/cluster.tf index b1fb0d2ff..811616c09 100644 --- a/modules/private-cluster/cluster.tf +++ b/modules/private-cluster/cluster.tf @@ -171,6 +171,7 @@ resource "google_container_node_pool" "pools" { auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade) } + node_config { image_type = lookup(each.value, "image_type", "COS") machine_type = lookup(each.value, "machine_type", "n1-standard-2")