Skip to content

Node pool autoscalling #2491

@lidor-ra

Description

@lidor-ra

TL;DR

You can't define maximum nor minimum instances via node_pool.autoscaling (making any node pool range to be from 0 to 100), or even referring to it at all.

Expected behavior

No response

Observed behavior

No response

Terraform Configuration

node_pool = {
    name = "nodepool-1"
    machine_type = "n2-highcpu-8"
    minimum = 1
    desired = 2
    maximum = 4
    autoscaling = {
      total_min_node_count = 2
      total_max_node_count = 4
    }
  }

Terraform Version

Terraform v1.14.0

Terraform Provider Versions

Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/random] >= 2.1.0
├── provider[registry.terraform.io/hashicorp/google] >= 7.0.0, < 8.0.0
└── provider[registry.terraform.io/hashicorp/kubernetes] ~> 2.10

Additional information

The main.tf code does refer the autoscaling, as follows:
dynamic "autoscaling" {
for_each = lookup(each.value, "autoscaling", true) ? [each.value] : []
content {
min_node_count = contains(keys(autoscaling.value), "total_min_count") ? null : lookup(autoscaling.value, "min_count", 1)
max_node_count = contains(keys(autoscaling.value), "total_max_count") ? null : lookup(autoscaling.value, "max_count", 100)
location_policy = lookup(autoscaling.value, "location_policy", null)
total_min_node_count = lookup(autoscaling.value, "total_min_count", null)
total_max_node_count = lookup(autoscaling.value, "total_max_count", null)
}
}

However, it's not possible to define such variable, e.g. defining:
node_pool = {
name = "np-1"
machine_type = "n2-highcpu-8"
minimum = 1
desired = 2
maximum = 4
autoscaling = {
total_min_node_count = 2
total_max_node_count = 4
}
}

Gives:
│ Error: Invalid value for input variable

│ on variables.tf line 176:
│ 176: variable "node_pools" {

│ Unsuitable value for var.node_pools set using the TF_VAR_node_pools
│ environment variable: element 0: all map elements must have the same type.

exit status 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions