Skip to content

Commit d59542c

Browse files
naveen230Tolseebharathkkb
authored
fix!: enable auto repair and upgrade with cluster autoscaling (#1530)
Co-authored-by: Tolsee <[email protected]> Co-authored-by: Bharath KKB <[email protected]>
1 parent 968b024 commit d59542c

File tree

32 files changed

+117
-19
lines changed

32 files changed

+117
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Then perform the following commands on the root folder:
131131
| add\_master\_webhook\_firewall\_rules | Create master\_webhook firewall rules for ports defined in `firewall_inbound_ports` | `bool` | `false` | no |
132132
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
133133
| 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 |
134-
| 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> 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> })</pre> | <pre>{<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 |
134+
| 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> 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> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<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 |
135135
| cluster\_dns\_domain | The suffix used for all cluster service records. | `string` | `""` | no |
136136
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED (default) or PLATFORM\_DEFAULT or CLOUD\_DNS. | `string` | `"PROVIDER_UNSPECIFIED"` | no |
137137
| 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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ resource "google_container_cluster" "primary" {
135135
content {
136136
service_account = local.service_account
137137
oauth_scopes = local.node_pools_oauth_scopes["all"]
138+
139+
management {
140+
auto_repair = lookup(var.cluster_autoscaling, "auto_repair", true)
141+
auto_upgrade = lookup(var.cluster_autoscaling, "auto_upgrade",true)
142+
}
143+
138144
{% if beta_cluster %}
139145
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
140146
{% endif %}

autogen/main/main.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ locals {
6868
resource_type = "memory"
6969
minimum = var.cluster_autoscaling.min_memory_gb
7070
maximum = var.cluster_autoscaling.max_memory_gb
71-
}], var.cluster_autoscaling.gpu_resources) : []
71+
}], var.cluster_autoscaling.gpu_resources) : []
7272
{% endif %}
7373

7474

autogen/main/variables.tf.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ variable "cluster_autoscaling" {
241241
min_memory_gb = number
242242
max_memory_gb = number
243243
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
244+
auto_repair = bool
245+
auto_upgrade = bool
244246
})
245247
default = {
246248
enabled = false
@@ -252,6 +254,8 @@ variable "cluster_autoscaling" {
252254
max_memory_gb = 0
253255
min_memory_gb = 0
254256
gpu_resources = []
257+
auto_repair = true
258+
auto_upgrade = true
255259
}
256260
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
257261
}

autogen/safer-cluster/variables.tf.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ variable "cluster_autoscaling" {
233233
min_memory_gb = number
234234
max_memory_gb = number
235235
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
236+
auto_repair = bool
237+
auto_upgrade = bool
236238
})
237239
default = {
238240
enabled = false
@@ -242,6 +244,8 @@ variable "cluster_autoscaling" {
242244
max_memory_gb = 0
243245
min_memory_gb = 0
244246
gpu_resources = []
247+
auto_repair = true
248+
auto_upgrade = true
245249
}
246250
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
247251
}

cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ resource "google_container_cluster" "primary" {
104104
content {
105105
service_account = local.service_account
106106
oauth_scopes = local.node_pools_oauth_scopes["all"]
107+
108+
management {
109+
auto_repair = lookup(var.cluster_autoscaling, "auto_repair", true)
110+
auto_upgrade = lookup(var.cluster_autoscaling, "auto_upgrade", true)
111+
}
112+
107113
}
108114
}
109115
dynamic "resource_limits" {

examples/node_pool/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This example illustrates how to create a cluster with multiple custom node-pool
77

88
| Name | Description | Type | Default | Required |
99
|------|-------------|------|---------|:--------:|
10-
| 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({<br> resource_type = string<br> minimum = number<br> maximum = number<br> }))<br> })</pre> | <pre>{<br> "autoscaling_profile": "BALANCED",<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 |
10+
| 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({<br> resource_type = string<br> minimum = number<br> maximum = number<br> }))<br> auto_repair = bool<br> auto_upgrade = bool<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<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 |
1111
| cluster\_name\_suffix | A suffix to append to the default cluster name | `string` | `""` | no |
1212
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `any` | n/a | yes |
1313
| ip\_range\_pods | The secondary ip range to use for pods | `any` | n/a | yes |

examples/node_pool/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ variable "cluster_autoscaling" {
6565
minimum = number
6666
maximum = number
6767
}))
68+
auto_repair = bool
69+
auto_upgrade = bool
6870
})
6971
default = {
7072
enabled = false
@@ -74,6 +76,8 @@ variable "cluster_autoscaling" {
7476
max_memory_gb = 0
7577
min_memory_gb = 0
7678
gpu_resources = []
79+
auto_repair = true
80+
auto_upgrade = true
7781
}
7882
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
7983
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Then perform the following commands on the root folder:
165165
| 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 |
166166
| cloudrun | (Beta) Enable CloudRun addon | `bool` | `false` | no |
167167
| 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 |
168-
| 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> })</pre> | <pre>{<br> "autoscaling_profile": "BALANCED",<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 |
168+
| 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> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<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 |
169169
| cluster\_dns\_domain | The suffix used for all cluster service records. | `string` | `""` | no |
170170
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED (default) or PLATFORM\_DEFAULT or CLOUD\_DNS. | `string` | `"PROVIDER_UNSPECIFIED"` | no |
171171
| 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: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,14 @@ resource "google_container_cluster" "primary" {
114114
for_each = var.cluster_autoscaling.enabled ? [1] : []
115115

116116
content {
117-
service_account = local.service_account
118-
oauth_scopes = local.node_pools_oauth_scopes["all"]
117+
service_account = local.service_account
118+
oauth_scopes = local.node_pools_oauth_scopes["all"]
119+
120+
management {
121+
auto_repair = lookup(var.cluster_autoscaling, "auto_repair", true)
122+
auto_upgrade = lookup(var.cluster_autoscaling, "auto_upgrade", true)
123+
}
124+
119125
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
120126
}
121127
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ variable "cluster_autoscaling" {
234234
min_memory_gb = number
235235
max_memory_gb = number
236236
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
237+
auto_repair = bool
238+
auto_upgrade = bool
237239
})
238240
default = {
239241
enabled = false
@@ -243,6 +245,8 @@ variable "cluster_autoscaling" {
243245
max_memory_gb = 0
244246
min_memory_gb = 0
245247
gpu_resources = []
248+
auto_repair = true
249+
auto_upgrade = true
246250
}
247251
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
248252
}

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Then perform the following commands on the root folder:
143143
| 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 |
144144
| cloudrun | (Beta) Enable CloudRun addon | `bool` | `false` | no |
145145
| 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 |
146-
| 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> })</pre> | <pre>{<br> "autoscaling_profile": "BALANCED",<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 |
146+
| 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> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<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 |
147147
| cluster\_dns\_domain | The suffix used for all cluster service records. | `string` | `""` | no |
148148
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED (default) or PLATFORM\_DEFAULT or CLOUD\_DNS. | `string` | `"PROVIDER_UNSPECIFIED"` | no |
149149
| 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: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,14 @@ resource "google_container_cluster" "primary" {
114114
for_each = var.cluster_autoscaling.enabled ? [1] : []
115115

116116
content {
117-
service_account = local.service_account
118-
oauth_scopes = local.node_pools_oauth_scopes["all"]
117+
service_account = local.service_account
118+
oauth_scopes = local.node_pools_oauth_scopes["all"]
119+
120+
management {
121+
auto_repair = lookup(var.cluster_autoscaling, "auto_repair", true)
122+
auto_upgrade = lookup(var.cluster_autoscaling, "auto_upgrade", true)
123+
}
124+
119125
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
120126
}
121127
}

modules/beta-private-cluster/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ variable "cluster_autoscaling" {
234234
min_memory_gb = number
235235
max_memory_gb = number
236236
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
237+
auto_repair = bool
238+
auto_upgrade = bool
237239
})
238240
default = {
239241
enabled = false
@@ -243,6 +245,8 @@ variable "cluster_autoscaling" {
243245
max_memory_gb = 0
244246
min_memory_gb = 0
245247
gpu_resources = []
248+
auto_repair = true
249+
auto_upgrade = true
246250
}
247251
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
248252
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Then perform the following commands on the root folder:
159159
| 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 |
160160
| cloudrun | (Beta) Enable CloudRun addon | `bool` | `false` | no |
161161
| 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 |
162-
| 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> })</pre> | <pre>{<br> "autoscaling_profile": "BALANCED",<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 |
162+
| 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> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<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 |
163163
| cluster\_dns\_domain | The suffix used for all cluster service records. | `string` | `""` | no |
164164
| cluster\_dns\_provider | Which in-cluster DNS provider should be used. PROVIDER\_UNSPECIFIED (default) or PLATFORM\_DEFAULT or CLOUD\_DNS. | `string` | `"PROVIDER_UNSPECIFIED"` | no |
165165
| 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-public-cluster-update-variant/cluster.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,14 @@ resource "google_container_cluster" "primary" {
114114
for_each = var.cluster_autoscaling.enabled ? [1] : []
115115

116116
content {
117-
service_account = local.service_account
118-
oauth_scopes = local.node_pools_oauth_scopes["all"]
117+
service_account = local.service_account
118+
oauth_scopes = local.node_pools_oauth_scopes["all"]
119+
120+
management {
121+
auto_repair = lookup(var.cluster_autoscaling, "auto_repair", true)
122+
auto_upgrade = lookup(var.cluster_autoscaling, "auto_upgrade", true)
123+
}
124+
119125
min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "")
120126
}
121127
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ variable "cluster_autoscaling" {
234234
min_memory_gb = number
235235
max_memory_gb = number
236236
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
237+
auto_repair = bool
238+
auto_upgrade = bool
237239
})
238240
default = {
239241
enabled = false
@@ -243,6 +245,8 @@ variable "cluster_autoscaling" {
243245
max_memory_gb = 0
244246
min_memory_gb = 0
245247
gpu_resources = []
248+
auto_repair = true
249+
auto_upgrade = true
246250
}
247251
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
248252
}

0 commit comments

Comments
 (0)