Closed jaohurtas closed 1 month ago
Note also that if I set node_count to 1 I get another error:
│ Error: expanding default_node_pool
: cannot change node_count
when enable_auto_scaling
is set to true
` # (24 unchanged attributes hidden)
~ default_node_pool {
~ max_count = 2 -> 1
~ min_count = 2 -> 1
name = "system"
~ node_count = 2 -> 1
tags = {
"createdWith" = "Terraform"
}
# (17 unchanged attributes hidden)
}
# (5 unchanged blocks hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy. module.aks_cluster.azurerm_kubernetes_cluster.aks_cluster: Modifying... [id=/subscriptions//resourceGroups//providers/Microsoft.ContainerService/managedClusters/***] ╷ `
Try not setting max_count
and min_count
. When autoscaling is disabled it reads node_count
not min_count
and max_count
. If you want autoscaling then don't specify node_count
however if you are setting min to 1 and max to 1 there is no need to set autoscaling
Try not setting
max_count
andmin_count
. When autoscaling is disabled it readsnode_count
notmin_count
andmax_count
. If you want autoscaling then don't specifynode_count
however if you are setting min to 1 and max to 1 there is no need to set autoscaling
I have auto-scaling enabled. I start with both max_count and min_count equal to 2 and need to be able to update those as needed. It is telling me the node_count setting is preventing changes to auto scale settings, and I never specified node_count.
I ran into this issue and think I identified the problem.
ExpandDefaultNodePool
(a function shared between update and create actions). https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/containers/kubernetes_cluster_resource.go#L2614node_count
from raw
, https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/containers/kubernetes_nodepool.go#L1366.count
has a value of 0 (because it's not set and it's a new resource), we'll set it to minCount, https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/containers/kubernetes_nodepool.go#L1376count
will just be whatever is the current node count.minCount
correctly checks whether we are creating the resource (rather than just updating it), by checking d.IsNewResource
: https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/containers/kubernetes_nodepool.go#L1399maxCount
does not: https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/containers/kubernetes_nodepool.go#L1389 . So we hit errors specifically while scaling down, setting maxCount
to a value below the current node count.So I think this could be fixed by updating https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/containers/kubernetes_nodepool.go#L1389 to be "if maxCount < count && d.IsNewResource()", matching the behavior on ln 1399 for minCount.
I may look into submitting a fix PR, but if someone wants to beat me to it, feel free :)
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Is there an existing issue for this?
Community Note
Terraform Version
1.2.8
AzureRM Provider Version
3.20.0
Affected Resource(s)/Data Source(s)
azurerm_kubernetes_cluster
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Auto scaling minimum and maximum node count set to 1
Actual Behaviour
Returns: Error: expanding
default_node_pool
:node_count
(2) must be equal to or less thanmax_count
(1) whenenable_auto_scaling
is set totrue
Steps to Reproduce
1) Set minimum and maximum autoscale not count to 2 and deploy 2) Do not configure default node count at any time 3) Set minimum and maximum autoscale node count to 1 and deploy
Returns: Error: expanding
default_node_pool
:node_count
(2) must be equal to or less thanmax_count
(1) whenenable_auto_scaling
is set totrue
Important Factoids
No response
References
No response