From 406f1a3bea117fedee8d9270f9b33b3018e4e408 Mon Sep 17 00:00:00 2001 From: ishuar Date: Thu, 7 Dec 2023 00:52:55 +0100 Subject: [PATCH 1/2] Added precondition for autoscaling and node pool type on default_node_pools --- main.tf | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.tf b/main.tf index d0a0507e..e5ef46fb 100644 --- a/main.tf +++ b/main.tf @@ -571,6 +571,10 @@ resource "azurerm_kubernetes_cluster" "main" { (var.client_id == "" || var.client_secret == "") && var.identity_type == "UserAssigned" && try(length(var.identity_ids), 0) > 0) error_message = "When `kubelet_identity` is enabled - The `type` field in the `identity` block must be set to `UserAssigned` and `identity_ids` must be set." } + precondition { + condition = !var.enable_auto_scaling || var.agents_type == "VirtualMachineScaleSets" + error_message = "Autoscaling on default node pools is only supported when the Kubernetes Cluster is using Virtual Machine Scale Sets type nodes." + } } } @@ -739,10 +743,6 @@ resource "azurerm_kubernetes_cluster_node_pool" "node_pool" { null_resource.pool_name_keeper[each.key], ] - precondition { - condition = var.agents_type == "VirtualMachineScaleSets" - error_message = "Multiple Node Pools are only supported when the Kubernetes Cluster is using Virtual Machine Scale Sets." - } precondition { condition = can(regex("[a-z0-9]{1,8}", each.value.name)) error_message = "A Node Pools name must consist of alphanumeric characters and have a maximum lenght of 8 characters (4 random chars added)" @@ -755,6 +755,10 @@ resource "azurerm_kubernetes_cluster_node_pool" "node_pool" { condition = var.network_plugin_mode != "overlay" || !can(regex("^Standard_DC[0-9]+s?_v2$", each.value.vm_size)) error_message = "With with Azure CNI Overlay you can't use DCsv2-series virtual machines in node pools. " } + precondition { + condition = var.agents_type == "VirtualMachineScaleSets" + error_message = "Multiple Node Pools are only supported when the Kubernetes Cluster is using Virtual Machine Scale Sets." + } } } From bd1dcb6ffe422547193a099b58a10c5c1aadb3c8 Mon Sep 17 00:00:00 2001 From: ishuar Date: Fri, 8 Dec 2023 02:52:43 +0100 Subject: [PATCH 2/2] Added precondition for autoscaling and node pool type on default_node_pools --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 24440420..79431f6d 100644 --- a/main.tf +++ b/main.tf @@ -572,7 +572,7 @@ resource "azurerm_kubernetes_cluster" "main" { error_message = "When `kubelet_identity` is enabled - The `type` field in the `identity` block must be set to `UserAssigned` and `identity_ids` must be set." } precondition { - condition = !var.enable_auto_scaling || var.agents_type == "VirtualMachineScaleSets" + condition = var.enable_auto_scaling != true || var.agents_type == "VirtualMachineScaleSets" error_message = "Autoscaling on default node pools is only supported when the Kubernetes Cluster is using Virtual Machine Scale Sets type nodes." } precondition {