Optimizing AKS: Resize Default Node Pool with Terraform Without Cluster Recreation

Rafael Medeiros
2 min readJan 6, 2024

If you have the requirement to resize an AKS cluster default node pool but you don’t want to delete the whole cluster to do so, here is the solution.

First of all, if you simply try to re-size the node pool, it will throw the following error that doesn’t help at all:

That is because one requirement from AKS is that it always need at least one node pool with “System” mode.

Let’s say you have another node pool in this cluster (like me), you can use it to be the “system” one during this maintenance time.
How do you do that?

Well, this is simple, you just need to add the following parameter to your second node pool:
mode = “System”

resource "azurerm_kubernetes_cluster_node_pool" "this" {
for_each = var.azure_kubernetes_clusters
name = "lin"
[…]
mode = "System"
os_type: "Linux"
}

Also, make sure that the second pool is Linux, otherwise, you’ll get the following error:

I highly recommend you to add a third nodepool if you are using the second one as Windows, instead of changing it to linux.

Change the size of the default pool and any other parameter you need.

After that, simply run terraform apply and you will see the result:

Don’t forget to delete the third node pool afterwards if you are not using it.

Happy Terraforming!

--

--

Rafael Medeiros

DevOps Engineer | 3x Azure | CKA | Terraform Fanatic | Another IT Professional willing to help the community