Skip to content

Commit 3569f13

Browse files
authored
feat!: support enabling default compute class in cluster autoscaler (#2442)
1 parent 8f610c7 commit 3569f13

File tree

37 files changed

+482
-530
lines changed

37 files changed

+482
-530
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Then perform the following commands on the root folder:
149149
| anonymous\_authentication\_config\_mode | Allows users to restrict or enable anonymous access to the cluster. Valid values are `ENABLED` and `LIMITED`. | `string` | `null` | no |
150150
| 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 gke-security-groups@yourdomain.com | `string` | `null` | no |
151151
| boot\_disk\_kms\_key | The Customer Managed Encryption Key used to encrypt the boot disk attached to each node in the node pool, if not overridden in `node_pools`. This should be of the form projects/[KEY\_PROJECT\_ID]/locations/[LOCATION]/keyRings/[RING\_NAME]/cryptoKeys/[KEY\_NAME]. For more information about protecting resources with Cloud KMS Keys please see: https://cloud.google.com/compute/docs/disks/customer-managed-encryption | `string` | `null` | 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 = optional(number)<br> max_cpu_cores = optional(number)<br> min_memory_gb = optional(number)<br> max_memory_gb = optional(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> image_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> enable_secure_boot = optional(bool, false)<br> enable_integrity_monitoring = optional(bool, true)<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> "enable_integrity_monitoring": true,<br> "enable_secure_boot": false,<br> "enabled": false,<br> "gpu_resources": [],<br> "image_type": "COS_CONTAINERD",<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 = optional(number)<br> max_cpu_cores = optional(number)<br> min_memory_gb = optional(number)<br> max_memory_gb = optional(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> image_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> enable_secure_boot = optional(bool, false)<br> enable_integrity_monitoring = optional(bool, true)<br> enable_default_compute_class = optional(bool, false)<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> "enable_default_compute_class": false,<br> "enable_integrity_monitoring": true,<br> "enable_secure_boot": false,<br> "enabled": false,<br> "gpu_resources": [],<br> "image_type": "COS_CONTAINERD",<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 |
@@ -160,7 +160,6 @@ Then perform the following commands on the root folder:
160160
| create\_service\_account | Defines if service account specified to run nodes should be created. | `bool` | `true` | no |
161161
| database\_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key\_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key\_name is the name of a CloudKMS key. | `list(object({ state = string, key_name = string }))` | <pre>[<br> {<br> "key_name": "",<br> "state": "DECRYPTED"<br> }<br>]</pre> | no |
162162
| datapath\_provider | The desired datapath provider for this cluster. By default, `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation. `ADVANCED_DATAPATH` enables Dataplane-V2 feature. | `string` | `"DATAPATH_PROVIDER_UNSPECIFIED"` | no |
163-
| default\_compute\_class\_enabled | Enable Spot VMs as the default compute class for Node Auto-Provisioning | `bool` | `null` | no |
164163
| default\_max\_pods\_per\_node | The maximum number of pods to schedule per node | `number` | `110` | no |
165164
| deletion\_protection | Whether or not to allow Terraform to destroy the cluster. | `bool` | `true` | no |
166165
| description | The description of the cluster | `string` | `""` | no |

autogen/main/cluster.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ resource "google_container_cluster" "primary" {
162162

163163
cluster_autoscaling {
164164
enabled = var.cluster_autoscaling.enabled
165-
default_compute_class_enabled = var.default_compute_class_enabled
165+
default_compute_class_enabled = lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
166166
dynamic "auto_provisioning_defaults" {
167167
for_each = var.cluster_autoscaling.enabled ? [1] : []
168168

autogen/main/variables.tf.tmpl

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -346,43 +346,45 @@ variable "enable_resource_consumption_export" {
346346
{% if autopilot_cluster != true %}
347347
variable "cluster_autoscaling" {
348348
type = object({
349-
enabled = bool
350-
autoscaling_profile = string
351-
min_cpu_cores = optional(number)
352-
max_cpu_cores = optional(number)
353-
min_memory_gb = optional(number)
354-
max_memory_gb = optional(number)
355-
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
356-
auto_repair = bool
357-
auto_upgrade = bool
358-
disk_size = optional(number)
359-
disk_type = optional(string)
360-
image_type = optional(string)
361-
strategy = optional(string)
362-
max_surge = optional(number)
363-
max_unavailable = optional(number)
364-
node_pool_soak_duration = optional(string)
365-
batch_soak_duration = optional(string)
366-
batch_percentage = optional(number)
367-
batch_node_count = optional(number)
368-
enable_secure_boot = optional(bool, false)
369-
enable_integrity_monitoring = optional(bool, true)
349+
enabled = bool
350+
autoscaling_profile = string
351+
min_cpu_cores = optional(number)
352+
max_cpu_cores = optional(number)
353+
min_memory_gb = optional(number)
354+
max_memory_gb = optional(number)
355+
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
356+
auto_repair = bool
357+
auto_upgrade = bool
358+
disk_size = optional(number)
359+
disk_type = optional(string)
360+
image_type = optional(string)
361+
strategy = optional(string)
362+
max_surge = optional(number)
363+
max_unavailable = optional(number)
364+
node_pool_soak_duration = optional(string)
365+
batch_soak_duration = optional(string)
366+
batch_percentage = optional(number)
367+
batch_node_count = optional(number)
368+
enable_secure_boot = optional(bool, false)
369+
enable_integrity_monitoring = optional(bool, true)
370+
enable_default_compute_class = optional(bool,false)
370371
})
371372
default = {
372-
enabled = false
373-
autoscaling_profile = "BALANCED"
374-
max_cpu_cores = 0
375-
min_cpu_cores = 0
376-
max_memory_gb = 0
377-
min_memory_gb = 0
378-
gpu_resources = []
379-
auto_repair = true
380-
auto_upgrade = true
381-
disk_size = 100
382-
disk_type = "pd-standard"
383-
image_type = "COS_CONTAINERD"
384-
enable_secure_boot = false
385-
enable_integrity_monitoring = true
373+
enabled = false
374+
autoscaling_profile = "BALANCED"
375+
max_cpu_cores = 0
376+
min_cpu_cores = 0
377+
max_memory_gb = 0
378+
min_memory_gb = 0
379+
gpu_resources = []
380+
auto_repair = true
381+
auto_upgrade = true
382+
disk_size = 100
383+
disk_type = "pd-standard"
384+
image_type = "COS_CONTAINERD"
385+
enable_secure_boot = false
386+
enable_integrity_monitoring = true
387+
enable_default_compute_class = false
386388
}
387389
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
388390
}
@@ -886,13 +888,14 @@ variable "enable_shielded_nodes" {
886888
}
887889

888890
{% endif %}
889-
891+
{% if autopilot_cluster == true %}
890892
variable "default_compute_class_enabled" {
891893
type = bool
892-
description = "Enable Spot VMs as the default compute class for Node Auto-Provisioning"
894+
description = "Enable default compute class for Node Auto-Provisioning"
893895
default = null
894896
}
895897

898+
{% endif %}
896899
variable "enable_binary_authorization" {
897900
type = bool
898901
description = "Enable BinAuthZ Admission controller"

cluster.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ resource "google_container_cluster" "primary" {
129129

130130
cluster_autoscaling {
131131
enabled = var.cluster_autoscaling.enabled
132-
default_compute_class_enabled = var.default_compute_class_enabled
132+
default_compute_class_enabled = lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
133133
dynamic "auto_provisioning_defaults" {
134134
for_each = var.cluster_autoscaling.enabled ? [1] : []
135135

metadata.yaml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -361,34 +361,36 @@ spec:
361361
description: Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)
362362
varType: |-
363363
object({
364-
enabled = bool
365-
autoscaling_profile = string
366-
min_cpu_cores = optional(number)
367-
max_cpu_cores = optional(number)
368-
min_memory_gb = optional(number)
369-
max_memory_gb = optional(number)
370-
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
371-
auto_repair = bool
372-
auto_upgrade = bool
373-
disk_size = optional(number)
374-
disk_type = optional(string)
375-
image_type = optional(string)
376-
strategy = optional(string)
377-
max_surge = optional(number)
378-
max_unavailable = optional(number)
379-
node_pool_soak_duration = optional(string)
380-
batch_soak_duration = optional(string)
381-
batch_percentage = optional(number)
382-
batch_node_count = optional(number)
383-
enable_secure_boot = optional(bool, false)
384-
enable_integrity_monitoring = optional(bool, true)
364+
enabled = bool
365+
autoscaling_profile = string
366+
min_cpu_cores = optional(number)
367+
max_cpu_cores = optional(number)
368+
min_memory_gb = optional(number)
369+
max_memory_gb = optional(number)
370+
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
371+
auto_repair = bool
372+
auto_upgrade = bool
373+
disk_size = optional(number)
374+
disk_type = optional(string)
375+
image_type = optional(string)
376+
strategy = optional(string)
377+
max_surge = optional(number)
378+
max_unavailable = optional(number)
379+
node_pool_soak_duration = optional(string)
380+
batch_soak_duration = optional(string)
381+
batch_percentage = optional(number)
382+
batch_node_count = optional(number)
383+
enable_secure_boot = optional(bool, false)
384+
enable_integrity_monitoring = optional(bool, true)
385+
enable_default_compute_class = optional(bool, false)
385386
})
386387
defaultValue:
387388
auto_repair: true
388389
auto_upgrade: true
389390
autoscaling_profile: BALANCED
390391
disk_size: 100
391392
disk_type: pd-standard
393+
enable_default_compute_class: false
392394
enable_integrity_monitoring: true
393395
enable_secure_boot: false
394396
enabled: false
@@ -667,9 +669,6 @@ spec:
667669
description: Enable Shielded Nodes features on all nodes in this cluster
668670
varType: bool
669671
defaultValue: true
670-
- name: default_compute_class_enabled
671-
description: Enable Spot VMs as the default compute class for Node Auto-Provisioning
672-
varType: bool
673672
- name: enable_binary_authorization
674673
description: Enable BinAuthZ Admission controller
675674
varType: bool

modules/beta-autopilot-private-cluster/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Then perform the following commands on the root folder:
8686
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | `map(string)` | `{}` | no |
8787
| create\_service\_account | Defines if service account specified to run nodes should be created. | `bool` | `true` | no |
8888
| database\_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key\_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key\_name is the name of a CloudKMS key. | `list(object({ state = string, key_name = string }))` | <pre>[<br> {<br> "key_name": "",<br> "state": "DECRYPTED"<br> }<br>]</pre> | no |
89-
| default\_compute\_class\_enabled | Enable Spot VMs as the default compute class for Node Auto-Provisioning | `bool` | `null` | no |
89+
| default\_compute\_class\_enabled | Enable default compute class for Node Auto-Provisioning | `bool` | `null` | no |
9090
| deletion\_protection | Whether or not to allow Terraform to destroy the cluster. | `bool` | `true` | no |
9191
| deploy\_using\_private\_endpoint | A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | `bool` | `false` | no |
9292
| description | The description of the cluster | `string` | `""` | no |

modules/beta-autopilot-private-cluster/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ spec:
453453
- key_name: ""
454454
state: DECRYPTED
455455
- name: default_compute_class_enabled
456-
description: Enable Spot VMs as the default compute class for Node Auto-Provisioning
456+
description: Enable default compute class for Node Auto-Provisioning
457457
varType: bool
458458
- name: enable_binary_authorization
459459
description: Enable BinAuthZ Admission controller

modules/beta-autopilot-private-cluster/variables.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,9 @@ variable "database_encryption" {
536536
}]
537537
}
538538

539-
540539
variable "default_compute_class_enabled" {
541540
type = bool
542-
description = "Enable Spot VMs as the default compute class for Node Auto-Provisioning"
541+
description = "Enable default compute class for Node Auto-Provisioning"
543542
default = null
544543
}
545544

modules/beta-autopilot-public-cluster/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Then perform the following commands on the root folder:
8080
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | `map(string)` | `{}` | no |
8181
| create\_service\_account | Defines if service account specified to run nodes should be created. | `bool` | `true` | no |
8282
| database\_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key\_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key\_name is the name of a CloudKMS key. | `list(object({ state = string, key_name = string }))` | <pre>[<br> {<br> "key_name": "",<br> "state": "DECRYPTED"<br> }<br>]</pre> | no |
83-
| default\_compute\_class\_enabled | Enable Spot VMs as the default compute class for Node Auto-Provisioning | `bool` | `null` | no |
83+
| default\_compute\_class\_enabled | Enable default compute class for Node Auto-Provisioning | `bool` | `null` | no |
8484
| deletion\_protection | Whether or not to allow Terraform to destroy the cluster. | `bool` | `true` | no |
8585
| description | The description of the cluster | `string` | `""` | no |
8686
| disable\_default\_snat | Whether to disable the default SNAT to support the private use of public IP addresses | `bool` | `false` | no |

modules/beta-autopilot-public-cluster/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ spec:
431431
- key_name: ""
432432
state: DECRYPTED
433433
- name: default_compute_class_enabled
434-
description: Enable Spot VMs as the default compute class for Node Auto-Provisioning
434+
description: Enable default compute class for Node Auto-Provisioning
435435
varType: bool
436436
- name: enable_binary_authorization
437437
description: Enable BinAuthZ Admission controller

0 commit comments

Comments
 (0)