Skip to content

Commit c87bb41

Browse files
authored
feat: Add upgrade_settings for NAP created node pools (terraform-google-modules#1908)
1 parent 11bae67 commit c87bb41

File tree

23 files changed

+303
-95
lines changed

23 files changed

+303
-95
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Then perform the following commands on the root folder:
138138
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
139139
| additional\_ip\_range\_pods | List of _names_ of the additional secondary subnet ip ranges to use for pods | `list(string)` | `[]` | no |
140140
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |
141-
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> auto_repair = bool<br> auto_upgrade = bool<br> disk_size = optional(number)<br> disk_type = optional(string)<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<br> "disk_size": 100,<br> "disk_type": "pd-standard",<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
141+
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> auto_repair = bool<br> auto_upgrade = bool<br> disk_size = optional(number)<br> disk_type = optional(string)<br> strategy = optional(string)<br> max_surge = optional(number)<br> max_unavailable = optional(number)<br> node_pool_soak_duration = optional(string)<br> batch_soak_duration = optional(string)<br> batch_percentage = optional(number)<br> batch_node_count = optional(number)<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<br> "disk_size": 100,<br> "disk_type": "pd-standard",<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
142142
| cluster\_dns\_domain | The suffix used for all cluster service records. | `string` | `""` | no |
143143
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED (default) or PLATFORM\_DEFAULT or CLOUD\_DNS. | `string` | `"PROVIDER_UNSPECIFIED"` | no |
144144
| cluster\_dns\_scope | The scope of access to cluster DNS records. DNS\_SCOPE\_UNSPECIFIED (default) or CLUSTER\_SCOPE or VPC\_SCOPE. | `string` | `"DNS_SCOPE_UNSPECIFIED"` | no |

autogen/main/cluster.tf.tmpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,25 @@ resource "google_container_cluster" "primary" {
147147
disk_size = lookup(var.cluster_autoscaling, "disk_size", 100)
148148
disk_type = lookup(var.cluster_autoscaling, "disk_type", "pd-standard")
149149

150+
upgrade_settings {
151+
strategy = lookup(var.cluster_autoscaling, "strategy", "SURGE")
152+
max_surge = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "SURGE" ? lookup(var.cluster_autoscaling, "max_surge", 0) : null
153+
max_unavailable = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "SURGE" ? lookup(var.cluster_autoscaling, "max_unavailable", 0) : null
154+
155+
dynamic "blue_green_settings" {
156+
for_each = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "BLUE_GREEN" ? [1] : []
157+
content {
158+
node_pool_soak_duration = lookup(var.cluster_autoscaling, "node_pool_soak_duration", null)
159+
160+
standard_rollout_policy {
161+
batch_soak_duration = lookup(var.cluster_autoscaling, "batch_soak_duration", null)
162+
batch_percentage = lookup(var.cluster_autoscaling, "batch_percentage", null)
163+
batch_node_count = lookup(var.cluster_autoscaling, "batch_node_count", null)
164+
}
165+
}
166+
}
167+
}
168+
150169
{% if beta_cluster %}
151170
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
152171
{% endif %}

autogen/main/variables.tf.tmpl

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,24 @@ variable "enable_resource_consumption_export" {
244244
{% if autopilot_cluster != true %}
245245
variable "cluster_autoscaling" {
246246
type = object({
247-
enabled = bool
248-
autoscaling_profile = string
249-
min_cpu_cores = number
250-
max_cpu_cores = number
251-
min_memory_gb = number
252-
max_memory_gb = number
253-
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
254-
auto_repair = bool
255-
auto_upgrade = bool
256-
disk_size = optional(number)
257-
disk_type = optional(string)
247+
enabled = bool
248+
autoscaling_profile = string
249+
min_cpu_cores = number
250+
max_cpu_cores = number
251+
min_memory_gb = number
252+
max_memory_gb = number
253+
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
254+
auto_repair = bool
255+
auto_upgrade = bool
256+
disk_size = optional(number)
257+
disk_type = optional(string)
258+
strategy = optional(string)
259+
max_surge = optional(number)
260+
max_unavailable = optional(number)
261+
node_pool_soak_duration = optional(string)
262+
batch_soak_duration = optional(string)
263+
batch_percentage = optional(number)
264+
batch_node_count = optional(number)
258265
})
259266
default = {
260267
enabled = false

cluster.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,25 @@ resource "google_container_cluster" "primary" {
120120
disk_size = lookup(var.cluster_autoscaling, "disk_size", 100)
121121
disk_type = lookup(var.cluster_autoscaling, "disk_type", "pd-standard")
122122

123+
upgrade_settings {
124+
strategy = lookup(var.cluster_autoscaling, "strategy", "SURGE")
125+
max_surge = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "SURGE" ? lookup(var.cluster_autoscaling, "max_surge", 0) : null
126+
max_unavailable = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "SURGE" ? lookup(var.cluster_autoscaling, "max_unavailable", 0) : null
127+
128+
dynamic "blue_green_settings" {
129+
for_each = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "BLUE_GREEN" ? [1] : []
130+
content {
131+
node_pool_soak_duration = lookup(var.cluster_autoscaling, "node_pool_soak_duration", null)
132+
133+
standard_rollout_policy {
134+
batch_soak_duration = lookup(var.cluster_autoscaling, "batch_soak_duration", null)
135+
batch_percentage = lookup(var.cluster_autoscaling, "batch_percentage", null)
136+
batch_node_count = lookup(var.cluster_autoscaling, "batch_node_count", null)
137+
}
138+
}
139+
}
140+
}
141+
123142
}
124143
}
125144
autoscaling_profile = var.cluster_autoscaling.autoscaling_profile != null ? var.cluster_autoscaling.autoscaling_profile : "BALANCED"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Then perform the following commands on the root folder:
171171
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |
172172
| cloudrun | (Beta) Enable CloudRun addon | `bool` | `false` | no |
173173
| cloudrun\_load\_balancer\_type | (Beta) Configure the Cloud Run load balancer type. External by default. Set to `LOAD_BALANCER_TYPE_INTERNAL` to configure as an internal load balancer. | `string` | `""` | no |
174-
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> auto_repair = bool<br> auto_upgrade = bool<br> disk_size = optional(number)<br> disk_type = optional(string)<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<br> "disk_size": 100,<br> "disk_type": "pd-standard",<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
174+
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> auto_repair = bool<br> auto_upgrade = bool<br> disk_size = optional(number)<br> disk_type = optional(string)<br> strategy = optional(string)<br> max_surge = optional(number)<br> max_unavailable = optional(number)<br> node_pool_soak_duration = optional(string)<br> batch_soak_duration = optional(string)<br> batch_percentage = optional(number)<br> batch_node_count = optional(number)<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<br> "disk_size": 100,<br> "disk_type": "pd-standard",<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
175175
| cluster\_dns\_domain | The suffix used for all cluster service records. | `string` | `""` | no |
176176
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED (default) or PLATFORM\_DEFAULT or CLOUD\_DNS. | `string` | `"PROVIDER_UNSPECIFIED"` | no |
177177
| cluster\_dns\_scope | The scope of access to cluster DNS records. DNS\_SCOPE\_UNSPECIFIED (default) or CLUSTER\_SCOPE or VPC\_SCOPE. | `string` | `"DNS_SCOPE_UNSPECIFIED"` | no |

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,25 @@ resource "google_container_cluster" "primary" {
126126
disk_size = lookup(var.cluster_autoscaling, "disk_size", 100)
127127
disk_type = lookup(var.cluster_autoscaling, "disk_type", "pd-standard")
128128

129+
upgrade_settings {
130+
strategy = lookup(var.cluster_autoscaling, "strategy", "SURGE")
131+
max_surge = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "SURGE" ? lookup(var.cluster_autoscaling, "max_surge", 0) : null
132+
max_unavailable = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "SURGE" ? lookup(var.cluster_autoscaling, "max_unavailable", 0) : null
133+
134+
dynamic "blue_green_settings" {
135+
for_each = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "BLUE_GREEN" ? [1] : []
136+
content {
137+
node_pool_soak_duration = lookup(var.cluster_autoscaling, "node_pool_soak_duration", null)
138+
139+
standard_rollout_policy {
140+
batch_soak_duration = lookup(var.cluster_autoscaling, "batch_soak_duration", null)
141+
batch_percentage = lookup(var.cluster_autoscaling, "batch_percentage", null)
142+
batch_node_count = lookup(var.cluster_autoscaling, "batch_node_count", null)
143+
}
144+
}
145+
}
146+
}
147+
129148
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
130149
}
131150
}

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,24 @@ variable "enable_resource_consumption_export" {
239239

240240
variable "cluster_autoscaling" {
241241
type = object({
242-
enabled = bool
243-
autoscaling_profile = string
244-
min_cpu_cores = number
245-
max_cpu_cores = number
246-
min_memory_gb = number
247-
max_memory_gb = number
248-
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
249-
auto_repair = bool
250-
auto_upgrade = bool
251-
disk_size = optional(number)
252-
disk_type = optional(string)
242+
enabled = bool
243+
autoscaling_profile = string
244+
min_cpu_cores = number
245+
max_cpu_cores = number
246+
min_memory_gb = number
247+
max_memory_gb = number
248+
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
249+
auto_repair = bool
250+
auto_upgrade = bool
251+
disk_size = optional(number)
252+
disk_type = optional(string)
253+
strategy = optional(string)
254+
max_surge = optional(number)
255+
max_unavailable = optional(number)
256+
node_pool_soak_duration = optional(string)
257+
batch_soak_duration = optional(string)
258+
batch_percentage = optional(number)
259+
batch_node_count = optional(number)
253260
})
254261
default = {
255262
enabled = false

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Then perform the following commands on the root folder:
149149
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |
150150
| cloudrun | (Beta) Enable CloudRun addon | `bool` | `false` | no |
151151
| cloudrun\_load\_balancer\_type | (Beta) Configure the Cloud Run load balancer type. External by default. Set to `LOAD_BALANCER_TYPE_INTERNAL` to configure as an internal load balancer. | `string` | `""` | no |
152-
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> auto_repair = bool<br> auto_upgrade = bool<br> disk_size = optional(number)<br> disk_type = optional(string)<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<br> "disk_size": 100,<br> "disk_type": "pd-standard",<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
152+
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> auto_repair = bool<br> auto_upgrade = bool<br> disk_size = optional(number)<br> disk_type = optional(string)<br> strategy = optional(string)<br> max_surge = optional(number)<br> max_unavailable = optional(number)<br> node_pool_soak_duration = optional(string)<br> batch_soak_duration = optional(string)<br> batch_percentage = optional(number)<br> batch_node_count = optional(number)<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<br> "disk_size": 100,<br> "disk_type": "pd-standard",<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
153153
| cluster\_dns\_domain | The suffix used for all cluster service records. | `string` | `""` | no |
154154
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED (default) or PLATFORM\_DEFAULT or CLOUD\_DNS. | `string` | `"PROVIDER_UNSPECIFIED"` | no |
155155
| cluster\_dns\_scope | The scope of access to cluster DNS records. DNS\_SCOPE\_UNSPECIFIED (default) or CLUSTER\_SCOPE or VPC\_SCOPE. | `string` | `"DNS_SCOPE_UNSPECIFIED"` | no |

modules/beta-private-cluster/cluster.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,25 @@ resource "google_container_cluster" "primary" {
126126
disk_size = lookup(var.cluster_autoscaling, "disk_size", 100)
127127
disk_type = lookup(var.cluster_autoscaling, "disk_type", "pd-standard")
128128

129+
upgrade_settings {
130+
strategy = lookup(var.cluster_autoscaling, "strategy", "SURGE")
131+
max_surge = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "SURGE" ? lookup(var.cluster_autoscaling, "max_surge", 0) : null
132+
max_unavailable = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "SURGE" ? lookup(var.cluster_autoscaling, "max_unavailable", 0) : null
133+
134+
dynamic "blue_green_settings" {
135+
for_each = lookup(var.cluster_autoscaling, "strategy", "SURGE") == "BLUE_GREEN" ? [1] : []
136+
content {
137+
node_pool_soak_duration = lookup(var.cluster_autoscaling, "node_pool_soak_duration", null)
138+
139+
standard_rollout_policy {
140+
batch_soak_duration = lookup(var.cluster_autoscaling, "batch_soak_duration", null)
141+
batch_percentage = lookup(var.cluster_autoscaling, "batch_percentage", null)
142+
batch_node_count = lookup(var.cluster_autoscaling, "batch_node_count", null)
143+
}
144+
}
145+
}
146+
}
147+
129148
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
130149
}
131150
}

0 commit comments

Comments
 (0)