Skip to content

Commit 4d840c2

Browse files
committed
feat: move enabling default compute class in cluster autoscaler for standard clusters
For standard clusters, which have the cluster_autoscaling block, move the enabling of default compute class to that block. For autopilot clusters, keep the enabling of default compute class in the main variables.tf file.
1 parent 839093c commit 4d840c2

File tree

38 files changed

+483
-531
lines changed

38 files changed

+483
-531
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
@@ -156,7 +156,7 @@ resource "google_container_cluster" "primary" {
156156

157157
cluster_autoscaling {
158158
enabled = var.cluster_autoscaling.enabled
159-
default_compute_class_enabled = var.default_compute_class_enabled
159+
default_compute_class_enabled = lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
160160
dynamic "auto_provisioning_defaults" {
161161
for_each = var.cluster_autoscaling.enabled ? [1] : []
162162

autogen/main/variables.tf.tmpl

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -324,43 +324,45 @@ variable "enable_resource_consumption_export" {
324324
{% if autopilot_cluster != true %}
325325
variable "cluster_autoscaling" {
326326
type = object({
327-
enabled = bool
328-
autoscaling_profile = string
329-
min_cpu_cores = optional(number)
330-
max_cpu_cores = optional(number)
331-
min_memory_gb = optional(number)
332-
max_memory_gb = optional(number)
333-
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
334-
auto_repair = bool
335-
auto_upgrade = bool
336-
disk_size = optional(number)
337-
disk_type = optional(string)
338-
image_type = optional(string)
339-
strategy = optional(string)
340-
max_surge = optional(number)
341-
max_unavailable = optional(number)
342-
node_pool_soak_duration = optional(string)
343-
batch_soak_duration = optional(string)
344-
batch_percentage = optional(number)
345-
batch_node_count = optional(number)
346-
enable_secure_boot = optional(bool, false)
347-
enable_integrity_monitoring = optional(bool, true)
327+
enabled = bool
328+
autoscaling_profile = string
329+
min_cpu_cores = optional(number)
330+
max_cpu_cores = optional(number)
331+
min_memory_gb = optional(number)
332+
max_memory_gb = optional(number)
333+
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
334+
auto_repair = bool
335+
auto_upgrade = bool
336+
disk_size = optional(number)
337+
disk_type = optional(string)
338+
image_type = optional(string)
339+
strategy = optional(string)
340+
max_surge = optional(number)
341+
max_unavailable = optional(number)
342+
node_pool_soak_duration = optional(string)
343+
batch_soak_duration = optional(string)
344+
batch_percentage = optional(number)
345+
batch_node_count = optional(number)
346+
enable_secure_boot = optional(bool, false)
347+
enable_integrity_monitoring = optional(bool, true)
348+
enable_default_compute_class = optional(bool,false)
348349
})
349350
default = {
350-
enabled = false
351-
autoscaling_profile = "BALANCED"
352-
max_cpu_cores = 0
353-
min_cpu_cores = 0
354-
max_memory_gb = 0
355-
min_memory_gb = 0
356-
gpu_resources = []
357-
auto_repair = true
358-
auto_upgrade = true
359-
disk_size = 100
360-
disk_type = "pd-standard"
361-
image_type = "COS_CONTAINERD"
362-
enable_secure_boot = false
363-
enable_integrity_monitoring = true
351+
enabled = false
352+
autoscaling_profile = "BALANCED"
353+
max_cpu_cores = 0
354+
min_cpu_cores = 0
355+
max_memory_gb = 0
356+
min_memory_gb = 0
357+
gpu_resources = []
358+
auto_repair = true
359+
auto_upgrade = true
360+
disk_size = 100
361+
disk_type = "pd-standard"
362+
image_type = "COS_CONTAINERD"
363+
enable_secure_boot = false
364+
enable_integrity_monitoring = true
365+
enable_default_compute_class = false
364366
}
365367
description = "Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)"
366368
}
@@ -864,13 +866,14 @@ variable "enable_shielded_nodes" {
864866
}
865867

866868
{% endif %}
867-
869+
{% if autopilot_cluster == true %}
868870
variable "default_compute_class_enabled" {
869871
type = bool
870-
description = "Enable Spot VMs as the default compute class for Node Auto-Provisioning"
872+
description = "Enable default compute class for Node Auto-Provisioning"
871873
default = null
872874
}
873875

876+
{% endif %}
874877
variable "enable_binary_authorization" {
875878
type = bool
876879
description = "Enable BinAuthZ Admission controller"

cluster.tf

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

124124
cluster_autoscaling {
125125
enabled = var.cluster_autoscaling.enabled
126-
default_compute_class_enabled = var.default_compute_class_enabled
126+
default_compute_class_enabled = lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
127127
dynamic "auto_provisioning_defaults" {
128128
for_each = var.cluster_autoscaling.enabled ? [1] : []
129129

metadata.yaml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -349,34 +349,36 @@ spec:
349349
description: Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling)
350350
varType: |-
351351
object({
352-
enabled = bool
353-
autoscaling_profile = string
354-
min_cpu_cores = optional(number)
355-
max_cpu_cores = optional(number)
356-
min_memory_gb = optional(number)
357-
max_memory_gb = optional(number)
358-
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
359-
auto_repair = bool
360-
auto_upgrade = bool
361-
disk_size = optional(number)
362-
disk_type = optional(string)
363-
image_type = optional(string)
364-
strategy = optional(string)
365-
max_surge = optional(number)
366-
max_unavailable = optional(number)
367-
node_pool_soak_duration = optional(string)
368-
batch_soak_duration = optional(string)
369-
batch_percentage = optional(number)
370-
batch_node_count = optional(number)
371-
enable_secure_boot = optional(bool, false)
372-
enable_integrity_monitoring = optional(bool, true)
352+
enabled = bool
353+
autoscaling_profile = string
354+
min_cpu_cores = optional(number)
355+
max_cpu_cores = optional(number)
356+
min_memory_gb = optional(number)
357+
max_memory_gb = optional(number)
358+
gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))
359+
auto_repair = bool
360+
auto_upgrade = bool
361+
disk_size = optional(number)
362+
disk_type = optional(string)
363+
image_type = optional(string)
364+
strategy = optional(string)
365+
max_surge = optional(number)
366+
max_unavailable = optional(number)
367+
node_pool_soak_duration = optional(string)
368+
batch_soak_duration = optional(string)
369+
batch_percentage = optional(number)
370+
batch_node_count = optional(number)
371+
enable_secure_boot = optional(bool, false)
372+
enable_integrity_monitoring = optional(bool, true)
373+
enable_default_compute_class = optional(bool, false)
373374
})
374375
defaultValue:
375376
auto_repair: true
376377
auto_upgrade: true
377378
autoscaling_profile: BALANCED
378379
disk_size: 100
379380
disk_type: pd-standard
381+
enable_default_compute_class: false
380382
enable_integrity_monitoring: true
381383
enable_secure_boot: false
382384
enabled: false
@@ -655,9 +657,6 @@ spec:
655657
description: Enable Shielded Nodes features on all nodes in this cluster
656658
varType: bool
657659
defaultValue: true
658-
- name: default_compute_class_enabled
659-
description: Enable Spot VMs as the default compute class for Node Auto-Provisioning
660-
varType: bool
661660
- name: enable_binary_authorization
662661
description: Enable BinAuthZ Admission controller
663662
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)