From 99c6b3712e9644ef35e84e8ba8ef14078e337796 Mon Sep 17 00:00:00 2001 From: Heng Lu <79895375+ms-henglu@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:32:43 +0800 Subject: [PATCH] `azurerm_kubernetes_cluster` - fix tests (#25200) * `azurerm_kubernetes_cluster` - fix tests * fix more * add deprecated message for Azure AD Integration (legacy) * add default value for max_surge * update * update * remove the block in 4.0 * deprecate managed * update more tests * update more tests --- ...kubernetes_cluster_addons_resource_test.go | 45 ++++ .../kubernetes_cluster_auth_resource_test.go | 48 ++++ .../kubernetes_cluster_data_source_test.go | 1 + ...ernetes_cluster_extension_resource_test.go | 3 + ...ubernetes_cluster_network_resource_test.go | 144 ++++++++++ .../kubernetes_cluster_node_pool_resource.go | 18 +- ...ernetes_cluster_node_pool_resource_test.go | 86 +++++- .../kubernetes_cluster_other_resource_test.go | 180 +++++++++++++ .../containers/kubernetes_cluster_resource.go | 245 +++++++++++------- .../kubernetes_cluster_resource_test.go | 30 +++ ...ubernetes_cluster_resource_upgrade_test.go | 14 +- ...ubernetes_cluster_scaling_resource_test.go | 55 ++++ ...bernetes_fleet_update_run_resource_test.go | 3 + 13 files changed, 775 insertions(+), 97 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_addons_resource_test.go b/internal/services/containers/kubernetes_cluster_addons_resource_test.go index 3934d017c63e..edb9d5e0af82 100644 --- a/internal/services/containers/kubernetes_cluster_addons_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_addons_resource_test.go @@ -352,6 +352,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } aci_connector_linux { @@ -412,6 +415,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -454,6 +460,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } azure_policy_enabled = %t @@ -514,6 +523,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } oms_agent { @@ -576,6 +588,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } oms_agent { @@ -619,6 +634,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -657,6 +675,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } http_application_routing_enabled = %t @@ -778,6 +799,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } ingress_application_gateway { @@ -824,6 +848,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } ingress_application_gateway { @@ -867,6 +894,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -919,6 +949,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } ingress_application_gateway { @@ -966,6 +999,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } open_service_mesh_enabled = %t @@ -1006,6 +1042,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } key_vault_secrets_provider { @@ -1049,6 +1088,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } confidential_computing { @@ -1091,6 +1133,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { diff --git a/internal/services/containers/kubernetes_cluster_auth_resource_test.go b/internal/services/containers/kubernetes_cluster_auth_resource_test.go index cf9fdc6f85c5..e8a9bfdf0cb4 100644 --- a/internal/services/containers/kubernetes_cluster_auth_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_auth_resource_test.go @@ -142,6 +142,7 @@ func TestAccKubernetesCluster_roleBasedAccessControlDisabled(t *testing.T) { } func TestAccKubernetesCluster_roleBasedAccessControlAAD(t *testing.T) { + t.Skip("Azure AD Integration (legacy) (https://aka.ms/aks/aad-legacy) is deprecated, the cluster could not be created with the Azure AD integration (legacy) enabled.") data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") r := KubernetesClusterResource{} clientData := data.Client() @@ -167,6 +168,7 @@ func TestAccKubernetesCluster_roleBasedAccessControlAAD(t *testing.T) { } func TestAccKubernetesCluster_roleBasedAccessControlAADUpdate(t *testing.T) { + t.Skip("Azure AD Integration (legacy) (https://aka.ms/aks/aad-legacy) is deprecated, the cluster could not be created with the Azure AD integration (legacy) enabled.") data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") r := KubernetesClusterResource{} @@ -193,6 +195,7 @@ func TestAccKubernetesCluster_roleBasedAccessControlAADUpdate(t *testing.T) { } func TestAccKubernetesCluster_roleBasedAccessControlAADUpdateToManaged(t *testing.T) { + t.Skip("Azure AD Integration (legacy) (https://aka.ms/aks/aad-legacy) is deprecated, the cluster could not be created with the Azure AD integration (legacy) enabled.") data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") r := KubernetesClusterResource{} clientData := data.Client() @@ -458,6 +461,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -501,6 +507,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -537,6 +546,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -575,6 +587,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -630,6 +645,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -675,6 +693,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -715,6 +736,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -755,6 +779,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -800,6 +827,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -845,6 +875,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -890,6 +923,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -934,6 +970,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 2 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -977,6 +1016,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1022,6 +1064,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1082,6 +1127,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } service_principal { diff --git a/internal/services/containers/kubernetes_cluster_data_source_test.go b/internal/services/containers/kubernetes_cluster_data_source_test.go index 374cdff2297c..1577bd6fa3df 100644 --- a/internal/services/containers/kubernetes_cluster_data_source_test.go +++ b/internal/services/containers/kubernetes_cluster_data_source_test.go @@ -89,6 +89,7 @@ func TestAccDataSourceKubernetesCluster_roleBasedAccessControlAAD_OlderKubernete } func TestAccDataSourceKubernetesCluster_roleBasedAccessControlAAD(t *testing.T) { + t.Skip("Azure AD Integration (legacy) (https://aka.ms/aks/aad-legacy) is deprecated, the cluster could not be created with the Azure AD integration (legacy) enabled.") data := acceptance.BuildTestData(t, "data.azurerm_kubernetes_cluster", "test") r := KubernetesClusterDataSource{} clientId := os.Getenv("ARM_CLIENT_ID") diff --git a/internal/services/containers/kubernetes_cluster_extension_resource_test.go b/internal/services/containers/kubernetes_cluster_extension_resource_test.go index 2addc8f48e7b..92704997a1c2 100644 --- a/internal/services/containers/kubernetes_cluster_extension_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_extension_resource_test.go @@ -134,6 +134,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { diff --git a/internal/services/containers/kubernetes_cluster_network_resource_test.go b/internal/services/containers/kubernetes_cluster_network_resource_test.go index b55c0c6aa917..0e9bbc63245c 100644 --- a/internal/services/containers/kubernetes_cluster_network_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_network_resource_test.go @@ -1127,6 +1127,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test1.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1178,6 +1181,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 2 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1235,6 +1241,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1292,6 +1301,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1358,6 +1370,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1423,6 +1438,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1488,6 +1506,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1549,6 +1570,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1599,6 +1623,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1650,6 +1677,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1729,6 +1759,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1808,6 +1841,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1847,6 +1883,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" enable_node_public_ip = true + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1901,6 +1940,9 @@ resource "azurerm_kubernetes_cluster" "test" { vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id max_pods = 60 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1940,6 +1982,9 @@ resource "azurerm_kubernetes_cluster" "test" { vm_size = "Standard_DS2_v2" enable_node_public_ip = true node_public_ip_prefix_id = azurerm_public_ip_prefix.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1971,6 +2016,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" max_pods = 60 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2011,6 +2059,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" max_pods = 60 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2095,6 +2146,9 @@ resource "azurerm_kubernetes_cluster" "test" { vm_size = "Standard_DS2_v2" max_pods = 60 vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2135,6 +2189,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" max_pods = 60 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2183,6 +2240,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2245,6 +2305,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2305,6 +2368,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } network_profile { @@ -2362,6 +2428,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2412,6 +2481,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2443,6 +2515,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } network_profile { @@ -2474,6 +2549,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } network_profile { @@ -2506,6 +2584,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } network_profile { @@ -2538,6 +2619,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } network_profile { @@ -2599,6 +2683,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2675,6 +2762,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2736,6 +2826,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2806,6 +2899,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2853,6 +2949,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } service_principal { @@ -2918,6 +3017,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2987,6 +3089,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3056,6 +3161,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3128,6 +3236,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3200,6 +3311,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3272,6 +3386,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3433,6 +3550,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 2 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3600,6 +3720,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 2 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3761,6 +3884,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 2 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3874,6 +4000,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 2 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3942,6 +4071,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -3991,6 +4123,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -4037,6 +4172,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -4082,6 +4220,9 @@ resource "azurerm_kubernetes_cluster" "test" { RoutingPreference = "Internet" } } + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -4128,6 +4269,9 @@ resource "azurerm_kubernetes_cluster" "test" { RoutingPreference = "Internet" } } + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/internal/services/containers/kubernetes_cluster_node_pool_resource.go index c8d90a1bbe22..8df9dabaeff7 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -1073,6 +1073,21 @@ func resourceKubernetesClusterNodePoolDelete(d *pluginsdk.ResourceData, meta int } func upgradeSettingsSchema() *pluginsdk.Schema { + if !features.FourPointOhBeta() { + return &pluginsdk.Schema{ + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "max_surge": { + Type: pluginsdk.TypeString, + Required: true, + }, + }, + }, + } + } return &pluginsdk.Schema{ Type: pluginsdk.TypeList, Optional: true, @@ -1081,7 +1096,8 @@ func upgradeSettingsSchema() *pluginsdk.Schema { Schema: map[string]*pluginsdk.Schema{ "max_surge": { Type: pluginsdk.TypeString, - Required: true, + Optional: true, + Default: "10%", }, }, }, diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go b/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go index b45bf64cee84..006053f67f0a 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go @@ -583,10 +583,11 @@ func TestAccKubernetesClusterNodePool_upgradeSettings(t *testing.T) { }, data.ImportStep(), { - Config: r.upgradeSettingsConfig(data, ""), + Config: r.upgradeSettingsConfig(data, "10%"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("upgrade_settings.#").HasValue("0"), + check.That(data.ResourceName).Key("upgrade_settings.#").HasValue("1"), + check.That(data.ResourceName).Key("upgrade_settings.0.max_surge").HasValue("10%"), ), }, data.ImportStep(), @@ -1226,6 +1227,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 type = "AvailabilitySet" vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1263,6 +1267,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1351,6 +1358,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1419,6 +1429,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1491,6 +1504,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_D2s_v3" capacity_reservation_group_id = azurerm_capacity_reservation.test.capacity_reservation_group_id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1852,6 +1868,9 @@ resource "azurerm_kubernetes_cluster" "test" { vm_size = "Standard_DS2_v2" pod_subnet_id = azurerm_subnet.podsubnet.id vnet_subnet_id = azurerm_subnet.nodesubnet.id + upgrade_settings { + max_surge = "10%%" + } } network_profile { network_plugin = "azure" @@ -1920,6 +1939,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2088,7 +2110,9 @@ resource "azurerm_kubernetes_cluster_node_pool" "test" { vm_size = "Standard_DS2_v2" node_count = 1 os_type = "Windows" - + windows_profile { + outbound_nat_enabled = true + } tags = { Os = "Windows" } @@ -2111,7 +2135,9 @@ resource "azurerm_kubernetes_cluster_node_pool" "test" { node_count = 1 os_type = "Windows" os_sku = "Windows2019" - + windows_profile { + outbound_nat_enabled = true + } tags = { Os = "Windows" } @@ -2134,7 +2160,9 @@ resource "azurerm_kubernetes_cluster_node_pool" "test" { node_count = 1 os_type = "Windows" os_sku = "Windows2022" - + windows_profile { + outbound_nat_enabled = true + } tags = { Os = "Windows" } @@ -2163,6 +2191,9 @@ resource "azurerm_kubernetes_cluster_node_pool" "windows" { vm_size = "Standard_DS2_v2" node_count = 1 os_type = "Windows" + windows_profile { + outbound_nat_enabled = true + } } `, r.templateWindowsConfig(data)) } @@ -2184,6 +2215,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2225,6 +2259,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" vnet_subnet_id = azurerm_subnet.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2251,6 +2288,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2388,6 +2428,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2421,6 +2464,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2484,6 +2530,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2544,6 +2593,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2576,6 +2628,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2608,6 +2663,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2642,6 +2700,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2691,6 +2752,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2737,6 +2801,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2783,6 +2850,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2817,6 +2887,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2867,6 +2940,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2s_v3" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" diff --git a/internal/services/containers/kubernetes_cluster_other_resource_test.go b/internal/services/containers/kubernetes_cluster_other_resource_test.go index 1a7165d33b1a..34d18891990a 100644 --- a/internal/services/containers/kubernetes_cluster_other_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_other_resource_test.go @@ -1170,6 +1170,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 type = "AvailabilitySet" vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1203,6 +1206,9 @@ resource "azurerm_kubernetes_cluster" "test" { vm_size = "Standard_DS2_v2" min_count = 1 max_count = 1 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1236,6 +1242,9 @@ resource "azurerm_kubernetes_cluster" "test" { enable_auto_scaling = true max_count = 10 min_count = 1 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1269,6 +1278,9 @@ resource "azurerm_kubernetes_cluster" "test" { enable_auto_scaling = true max_count = 10 min_count = 1 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1302,6 +1314,9 @@ resource "azurerm_kubernetes_cluster" "test" { enable_auto_scaling = true max_count = 10 min_count = 1 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1335,6 +1350,9 @@ resource "azurerm_kubernetes_cluster" "test" { min_count = 1 max_count = 1000 node_count = 1 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1368,6 +1386,9 @@ resource "azurerm_kubernetes_cluster" "test" { enable_auto_scaling = true max_count = 10 min_count = 2 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1398,6 +1419,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1421,6 +1445,9 @@ resource "azurerm_kubernetes_cluster" "import" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1453,6 +1480,9 @@ resource "azurerm_kubernetes_cluster" "test" { type = "AvailabilitySet" vm_size = "Standard_DS2_v2" only_critical_addons_enabled = true + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1484,6 +1514,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" temporary_name_for_rotation = "temp" + upgrade_settings { + max_surge = "10%%" + } kubelet_config { cpu_manager_policy = "static" cpu_cfs_quota_enabled = true @@ -1565,6 +1598,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" temporary_name_for_rotation = "temp" + upgrade_settings { + max_surge = "10%%" + } kubelet_config { cpu_manager_policy = "static" cpu_cfs_quota_enabled = true @@ -1619,6 +1655,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1650,6 +1689,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } node_labels = { %s } @@ -1684,6 +1726,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1718,6 +1763,9 @@ resource "azurerm_kubernetes_cluster" "test" { kubelet_disk_type = "OS" message_of_the_day = "daily message" workload_runtime = "OCIContainer" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1751,6 +1799,9 @@ resource "azurerm_kubernetes_cluster" "test" { message_of_the_day = "daily message" os_sku = "Mariner" workload_runtime = "KataMshvVmIsolation" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1782,6 +1833,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1839,6 +1893,9 @@ resource "azurerm_kubernetes_cluster" "test" { vm_size = "Standard_DS2_v2" pod_subnet_id = azurerm_subnet.podsubnet.id vnet_subnet_id = azurerm_subnet.nodesubnet.id + upgrade_settings { + max_surge = "10%%" + } } network_profile { network_plugin = "azure" @@ -1871,6 +1928,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1901,6 +1961,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1935,6 +1998,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1978,6 +2044,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2026,6 +2095,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "np" node_count = 3 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2078,6 +2150,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "np" node_count = 3 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2203,6 +2278,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "np" node_count = 3 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2256,6 +2334,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" vm_size = "Standard_DS2_v2" node_count = 1 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2287,6 +2368,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" vm_size = "Standard_DS2_v2" node_count = 1 + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2316,6 +2400,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2352,6 +2439,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2386,6 +2476,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2450,6 +2543,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_D2s_v3" capacity_reservation_group_id = azurerm_capacity_reservation.test.capacity_reservation_group_id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2487,6 +2583,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2535,6 +2634,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2591,6 +2693,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2640,6 +2745,9 @@ resource "azurerm_kubernetes_cluster" "test" { vm_size = "Standard_D2s_v3" ultra_ssd_enabled = %t zones = ["1", "2", "3"] + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2671,6 +2779,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" scale_down_mode = "%s" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2698,6 +2809,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2734,6 +2848,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_D2s_v3" os_sku = "%s" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2762,6 +2879,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_D2s_v3" os_sku = "Ubuntu" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2790,6 +2910,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_D2s_v3" os_sku = "Ubuntu" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2826,6 +2949,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2862,6 +2988,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -2896,6 +3025,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2935,6 +3067,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -2974,6 +3109,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3009,6 +3147,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3041,6 +3182,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_D2s_v3" custom_ca_trust_enabled = "%t" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -3070,6 +3214,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3103,6 +3250,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3138,6 +3288,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3167,6 +3320,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" vm_size = "Standard_DS2_v2" node_count = 1 + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -3192,6 +3348,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" vm_size = "Standard_DS2_v2" node_count = 1 + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -3226,6 +3385,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -3255,6 +3417,9 @@ resource "azurerm_kubernetes_cluster" "source" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -3283,6 +3448,9 @@ resource "azurerm_kubernetes_cluster" "source" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -3304,6 +3472,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" snapshot_id = data.azurerm_kubernetes_node_pool_snapshot.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -3334,6 +3505,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_NC24ads_A100_v4" gpu_instance = "MIG1g" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -3364,6 +3538,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" vm_size = "Standard_DS2_v2" node_count = 1 + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -3393,6 +3570,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" vm_size = "Standard_DS2_v2" node_count = 1 + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" diff --git a/internal/services/containers/kubernetes_cluster_resource.go b/internal/services/containers/kubernetes_cluster_resource.go index 87b319ed1fea..3891945e1e95 100644 --- a/internal/services/containers/kubernetes_cluster_resource.go +++ b/internal/services/containers/kubernetes_cluster_resource.go @@ -296,40 +296,6 @@ func resourceKubernetesCluster() *pluginsdk.Resource { MaxItems: 1, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "client_app_id": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.IsUUID, - AtLeastOneOf: []string{ - "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", - "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", - "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", - }, - }, - - "server_app_id": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.IsUUID, - AtLeastOneOf: []string{ - "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", - "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", - "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", - }, - }, - - "server_app_secret": { - Type: pluginsdk.TypeString, - Optional: true, - Sensitive: true, - ValidateFunc: validation.StringIsNotEmpty, - AtLeastOneOf: []string{ - "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", - "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", - "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", - }, - }, - "tenant_id": { Type: pluginsdk.TypeString, Optional: true, @@ -337,19 +303,9 @@ func resourceKubernetesCluster() *pluginsdk.Resource { // OrEmpty since this can be sourced from the client config if it's not specified ValidateFunc: validation.Any(validation.IsUUID, validation.StringIsEmpty), AtLeastOneOf: []string{ - "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", - "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", - "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", - }, - }, - - "managed": { - Type: pluginsdk.TypeBool, - Optional: true, - AtLeastOneOf: []string{ - "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", - "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", - "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", + "azure_active_directory_role_based_access_control.0.tenant_id", + "azure_active_directory_role_based_access_control.0.managed", + "azure_active_directory_role_based_access_control.0.admin_group_object_ids", }, }, @@ -366,9 +322,9 @@ func resourceKubernetesCluster() *pluginsdk.Resource { ValidateFunc: validation.IsUUID, }, AtLeastOneOf: []string{ - "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", - "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", - "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", + "azure_active_directory_role_based_access_control.0.tenant_id", + "azure_active_directory_role_based_access_control.0.managed", + "azure_active_directory_role_based_access_control.0.admin_group_object_ids", }, }, }, @@ -1587,6 +1543,94 @@ func resourceKubernetesCluster() *pluginsdk.Resource { }, false), Deprecated: features.DeprecatedInFourPointOh("The property `node_os_channel_upgrade` will be renamed to `node_os_upgrade_channel` in v4.0 of the AzureRM Provider."), } + resource.Schema["azure_active_directory_role_based_access_control"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "client_app_id": { + Deprecated: "Azure AD Integration (legacy) (https://aka.ms/aks/aad-legacy) is deprecated and clusters can no longer be created with the Azure AD integration (legacy) enabled. This field will be removed in v4.0 of the AzureRM Provider.", + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.IsUUID, + AtLeastOneOf: []string{ + "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", + "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", + "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", + }, + }, + + "server_app_id": { + Deprecated: "Azure AD Integration (legacy) (https://aka.ms/aks/aad-legacy) is deprecated and clusters can no longer be created with the Azure AD integration (legacy) enabled. This field will be removed in v4.0 of the AzureRM Provider.", + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.IsUUID, + AtLeastOneOf: []string{ + "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", + "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", + "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", + }, + }, + + "server_app_secret": { + Deprecated: "Azure AD Integration (legacy) (https://aka.ms/aks/aad-legacy) is deprecated and clusters can no longer be created with the Azure AD integration (legacy) enabled. This field will be removed in v4.0 of the AzureRM Provider.", + Type: pluginsdk.TypeString, + Optional: true, + Sensitive: true, + ValidateFunc: validation.StringIsNotEmpty, + AtLeastOneOf: []string{ + "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", + "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", + "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", + }, + }, + + "tenant_id": { + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + // OrEmpty since this can be sourced from the client config if it's not specified + ValidateFunc: validation.Any(validation.IsUUID, validation.StringIsEmpty), + AtLeastOneOf: []string{ + "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", + "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", + "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", + }, + }, + + "managed": { + Deprecated: "Azure AD Integration (legacy) (https://aka.ms/aks/aad-legacy) is deprecated and clusters can no longer be created with the Azure AD integration (legacy) enabled. This field will be removed in v4.0 of the AzureRM Provider.", + Type: pluginsdk.TypeBool, + Optional: true, + AtLeastOneOf: []string{ + "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", + "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", + "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", + }, + }, + + "azure_rbac_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + }, + + "admin_group_object_ids": { + Type: pluginsdk.TypeList, + Optional: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + ValidateFunc: validation.IsUUID, + }, + AtLeastOneOf: []string{ + "azure_active_directory_role_based_access_control.0.client_app_id", "azure_active_directory_role_based_access_control.0.server_app_id", + "azure_active_directory_role_based_access_control.0.server_app_secret", "azure_active_directory_role_based_access_control.0.tenant_id", + "azure_active_directory_role_based_access_control.0.managed", "azure_active_directory_role_based_access_control.0.admin_group_object_ids", + }, + }, + }, + }, + } } if features.FourPointOhBeta() { @@ -3662,10 +3706,20 @@ func expandKubernetesClusterAzureActiveDirectoryRoleBasedAccessControl(input []i return nil, nil } - var aad *managedclusters.ManagedClusterAADProfile - azureAdRaw := input[0].(map[string]interface{}) + if features.FourPointOhBeta() { + adminGroupObjectIdsRaw := azureAdRaw["admin_group_object_ids"].([]interface{}) + adminGroupObjectIds := utils.ExpandStringSlice(adminGroupObjectIdsRaw) + return &managedclusters.ManagedClusterAADProfile{ + TenantID: pointer.To(azureAdRaw["tenant_id"].(string)), + Managed: pointer.To(true), + AdminGroupObjectIDs: adminGroupObjectIds, + EnableAzureRBAC: pointer.To(azureAdRaw["azure_rbac_enabled"].(bool)), + }, nil + } + + var aad *managedclusters.ManagedClusterAADProfile clientAppId := azureAdRaw["client_app_id"].(string) serverAppId := azureAdRaw["server_app_id"].(string) serverAppSecret := azureAdRaw["server_app_secret"].(string) @@ -3737,55 +3791,68 @@ func expandKubernetesClusterManagedClusterIdentity(input []interface{}) (*identi func flattenKubernetesClusterAzureActiveDirectoryRoleBasedAccessControl(input *managedclusters.ManagedClusterProperties, d *pluginsdk.ResourceData) []interface{} { results := make([]interface{}, 0) - if profile := input.AadProfile; profile != nil { - adminGroupObjectIds := utils.FlattenStringSlice(profile.AdminGroupObjectIDs) + if !features.FourPointOhBeta() { + if profile := input.AadProfile; profile != nil { + adminGroupObjectIds := utils.FlattenStringSlice(profile.AdminGroupObjectIDs) - clientAppId := "" - if profile.ClientAppID != nil { - clientAppId = *profile.ClientAppID - } + clientAppId := "" + if profile.ClientAppID != nil { + clientAppId = *profile.ClientAppID + } - managed := false - if profile.Managed != nil { - managed = *profile.Managed - } + managed := false + if profile.Managed != nil { + managed = *profile.Managed + } - azureRbacEnabled := false - if profile.EnableAzureRBAC != nil { - azureRbacEnabled = *profile.EnableAzureRBAC - } + azureRbacEnabled := false + if profile.EnableAzureRBAC != nil { + azureRbacEnabled = *profile.EnableAzureRBAC + } - serverAppId := "" - if profile.ServerAppID != nil { - serverAppId = *profile.ServerAppID - } + serverAppId := "" + if profile.ServerAppID != nil { + serverAppId = *profile.ServerAppID + } - serverAppSecret := "" - // since input.ServerAppSecret isn't returned we're pulling this out of the existing state (which won't work for Imports) - // azure_active_directory_role_based_access_control.0.server_app_secret - if existing, ok := d.GetOk("azure_active_directory_role_based_access_control"); ok { - aadRbacRaw := existing.([]interface{}) - if len(aadRbacRaw) > 0 { - aadRbac := aadRbacRaw[0].(map[string]interface{}) - if v := aadRbac["server_app_secret"]; v != nil { - serverAppSecret = v.(string) + serverAppSecret := "" + // since input.ServerAppSecret isn't returned we're pulling this out of the existing state (which won't work for Imports) + // azure_active_directory_role_based_access_control.0.server_app_secret + if existing, ok := d.GetOk("azure_active_directory_role_based_access_control"); ok { + aadRbacRaw := existing.([]interface{}) + if len(aadRbacRaw) > 0 { + aadRbac := aadRbacRaw[0].(map[string]interface{}) + if v := aadRbac["server_app_secret"]; v != nil { + serverAppSecret = v.(string) + } } } - } - tenantId := "" - if profile.TenantID != nil { - tenantId = *profile.TenantID + tenantId := "" + if profile.TenantID != nil { + tenantId = *profile.TenantID + } + + results = append(results, map[string]interface{}{ + "admin_group_object_ids": adminGroupObjectIds, + "client_app_id": clientAppId, + "managed": managed, + "server_app_id": serverAppId, + "server_app_secret": serverAppSecret, + "tenant_id": tenantId, + "azure_rbac_enabled": azureRbacEnabled, + }) } + return results + } + + if profile := input.AadProfile; profile != nil { + adminGroupObjectIds := utils.FlattenStringSlice(profile.AdminGroupObjectIDs) results = append(results, map[string]interface{}{ "admin_group_object_ids": adminGroupObjectIds, - "client_app_id": clientAppId, - "managed": managed, - "server_app_id": serverAppId, - "server_app_secret": serverAppSecret, - "tenant_id": tenantId, - "azure_rbac_enabled": azureRbacEnabled, + "tenant_id": pointer.From(profile.TenantID), + "azure_rbac_enabled": pointer.From(profile.EnableAzureRBAC), }) } diff --git a/internal/services/containers/kubernetes_cluster_resource_test.go b/internal/services/containers/kubernetes_cluster_resource_test.go index 1aa3aaa8cadd..9a1dc9f8cb4a 100644 --- a/internal/services/containers/kubernetes_cluster_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_resource_test.go @@ -291,6 +291,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" enable_host_encryption = true + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -350,6 +353,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_D2s_v3" host_group_id = azurerm_dedicated_host_group.test.id + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -388,6 +394,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -423,6 +432,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -458,6 +470,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -492,6 +507,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -580,6 +598,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { type = "SystemAssigned" @@ -661,6 +682,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -694,6 +718,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -733,6 +760,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { diff --git a/internal/services/containers/kubernetes_cluster_resource_upgrade_test.go b/internal/services/containers/kubernetes_cluster_resource_upgrade_test.go index e8e42aace9c2..320865744770 100644 --- a/internal/services/containers/kubernetes_cluster_resource_upgrade_test.go +++ b/internal/services/containers/kubernetes_cluster_resource_upgrade_test.go @@ -288,10 +288,11 @@ func TestAccKubernetesCluster_upgradeSettings(t *testing.T) { }, data.ImportStep(), { - Config: r.upgradeSettingsConfig(data, ""), + Config: r.upgradeSettingsConfig(data, "10%"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("default_node_pool.0.upgrade_settings.#").HasValue("0"), + check.That(data.ResourceName).Key("default_node_pool.0.upgrade_settings.#").HasValue("1"), + check.That(data.ResourceName).Key("default_node_pool.0.upgrade_settings.0.max_surge").HasValue("10%"), ), }, data.ImportStep(), @@ -329,6 +330,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -361,6 +365,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" orchestrator_version = %q + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -431,6 +438,9 @@ resource "azurerm_kubernetes_cluster" "test" { enable_auto_scaling = true min_count = %d max_count = %d + upgrade_settings { + max_surge = "10%%" + } } identity { diff --git a/internal/services/containers/kubernetes_cluster_scaling_resource_test.go b/internal/services/containers/kubernetes_cluster_scaling_resource_test.go index c8f3bfa0d966..8fa16d755008 100644 --- a/internal/services/containers/kubernetes_cluster_scaling_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_scaling_resource_test.go @@ -483,6 +483,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -519,6 +522,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "Standard_DS2_v2" enable_host_encryption = true + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -554,6 +560,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_D2ads_v5" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -590,6 +599,9 @@ resource "azurerm_kubernetes_cluster" "test" { temporary_name_for_rotation = "temp" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -627,6 +639,9 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "%s" enable_host_encryption = false + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -677,6 +692,9 @@ resource "azurerm_kubernetes_cluster" "test" { vm_swappiness = 40 } } + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -726,6 +744,10 @@ resource "azurerm_kubernetes_cluster" "test" { vm_swappiness = 45 } } + + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -762,6 +784,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -800,6 +825,9 @@ resource "azurerm_kubernetes_cluster" "test" { os_disk_type = "%s" os_disk_size_gb = %d vm_size = "Standard_D2ads_v5" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -847,6 +875,9 @@ resource "azurerm_kubernetes_cluster" "test" { vm_swappiness = 40 } } + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -882,6 +913,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = %d vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -917,6 +951,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -957,6 +994,9 @@ resource "azurerm_kubernetes_cluster" "test" { tags = { Hello = "World" } + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -995,6 +1035,9 @@ resource "azurerm_kubernetes_cluster" "test" { min_count = 2 max_count = 4 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1027,6 +1070,9 @@ resource "azurerm_kubernetes_cluster" "test" { max_count = 2 enable_auto_scaling = true vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1061,6 +1107,9 @@ resource "azurerm_kubernetes_cluster" "test" { enable_auto_scaling = true vm_size = "Standard_DS2_v2" zones = ["1", "2"] + upgrade_settings { + max_surge = "10%%" + } } identity { @@ -1098,6 +1147,9 @@ resource "azurerm_kubernetes_cluster" "test" { min_count = 2 max_count = 4 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } auto_scaler_profile { @@ -1135,6 +1187,9 @@ resource "azurerm_kubernetes_cluster" "test" { min_count = 2 max_count = 4 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } auto_scaler_profile { diff --git a/internal/services/containers/kubernetes_fleet_update_run_resource_test.go b/internal/services/containers/kubernetes_fleet_update_run_resource_test.go index 3482a801a9cf..aef52915d8ff 100644 --- a/internal/services/containers/kubernetes_fleet_update_run_resource_test.go +++ b/internal/services/containers/kubernetes_fleet_update_run_resource_test.go @@ -203,6 +203,9 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" + upgrade_settings { + max_surge = "10%%" + } } identity {