diff --git a/src/aks-preview/HISTORY.rst b/src/aks-preview/HISTORY.rst index b86f428bfed..160d16426ed 100644 --- a/src/aks-preview/HISTORY.rst +++ b/src/aks-preview/HISTORY.rst @@ -9,6 +9,10 @@ If there is no rush to release a new version, please just add a description of t To release a new version, please select a new version number (usually plus 1 to last patch version, X.Y.Z -> Major.Minor.Patch, more details in `\doc `_), and then add a new section named as the new version number in this file, the content should include the new modifications and everything from the *Pending* section. Finally, update the `VERSION` variable in `setup.py` with this new version number. +13.0.0b3 ++++++++ +* `az aks create`: Update outbound type selection logic for automatic cluster when customer brings BYO Vnet. + 13.0.0b2 +++++++ * `az aks create/update`: Update advanced container networking service (acns) with 2024-09-02-preview API version enablement. diff --git a/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py b/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py index 268b9e89a96..5453a779da9 100644 --- a/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py +++ b/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py @@ -433,8 +433,9 @@ def _get_outbound_type( ): outbound_type = CONST_OUTBOUND_TYPE_LOAD_BALANCER skuName = self.get_sku_name() - if skuName is not None and skuName == CONST_MANAGED_CLUSTER_SKU_NAME_AUTOMATIC: - # outbound_type of Automatic SKU should be ManagedNATGateway if not provided. + isVnetSubnetIdEmpty = self.get_vnet_subnet_id() in ["", None] + if skuName is not None and skuName == CONST_MANAGED_CLUSTER_SKU_NAME_AUTOMATIC and isVnetSubnetIdEmpty: + # outbound_type of Automatic SKU should be ManagedNATGateway if no subnet id provided. outbound_type = CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY # validation @@ -1425,6 +1426,7 @@ def _get_apiserver_subnet_id(self, enable_validation: bool = False) -> Union[str enable_apiserver_vnet_integration is None or enable_apiserver_vnet_integration is False ) + and self.get_sku_name() != CONST_MANAGED_CLUSTER_SKU_NAME_AUTOMATIC ): raise RequiredArgumentMissingError( '"--apiserver-subnet-id" requires "--enable-apiserver-vnet-integration".') @@ -2923,6 +2925,9 @@ def set_up_api_server_access_profile(self, mc: ManagedCluster) -> ManagedCluster mc.api_server_access_profile = self.models.ManagedClusterAPIServerAccessProfile() mc.api_server_access_profile.enable_vnet_integration = True if self.context.get_apiserver_subnet_id(): + if mc.api_server_access_profile is None: + # pylint: disable=no-member + mc.api_server_access_profile = self.models.ManagedClusterAPIServerAccessProfile() mc.api_server_access_profile.subnet_id = self.context.get_apiserver_subnet_id() return mc diff --git a/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py b/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py index 61ba8d297a7..3461b8095f8 100644 --- a/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py +++ b/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py @@ -3958,6 +3958,7 @@ def test_get_outbound_type(self): self.models, decorator_mode=DecoratorMode.CREATE, ) + self.create_attach_agentpool_context(ctx1) outbound_type_1 = ctx1._get_outbound_type(False, False, None) expect_outbound_type_1 = CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY self.assertEqual(outbound_type_1,expect_outbound_type_1) @@ -3968,10 +3969,33 @@ def test_get_outbound_type(self): self.models, decorator_mode=DecoratorMode.CREATE, ) + self.create_attach_agentpool_context(ctx2) outbound_type_2 = ctx2._get_outbound_type(False, False, None) expect_outbound_type_2 = CONST_OUTBOUND_TYPE_LOAD_BALANCER self.assertEqual(outbound_type_2,expect_outbound_type_2) + ctx3 = AKSPreviewManagedClusterContext( + self.cmd, + AKSManagedClusterParamDict({"sku": "automatic", "vnet_subnet_id": "/subscriptions/testid/resourceGroups/MockedResourceGroup/providers/Microsoft.Network/virtualNetworks/MockedNetworkId/subnets/MockedSubNetId"}), + self.models, + decorator_mode=DecoratorMode.CREATE, + ) + self.create_attach_agentpool_context(ctx3) + outbound_type_3 = ctx3._get_outbound_type(False, False, None) + expect_outbound_type_3 = CONST_OUTBOUND_TYPE_LOAD_BALANCER + self.assertEqual(outbound_type_3,expect_outbound_type_3) + + ctx4 = AKSPreviewManagedClusterContext( + self.cmd, + AKSManagedClusterParamDict({"sku": "automatic"}), + self.models, + decorator_mode=DecoratorMode.CREATE, + ) + self.create_attach_agentpool_context(ctx4) + outbound_type_4 = ctx4._get_outbound_type(False, False, None) + expect_outbound_type_4 = CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY + self.assertEqual(outbound_type_4,expect_outbound_type_4) + class AKSPreviewManagedClusterCreateDecoratorTestCase(unittest.TestCase): def setUp(self): # manually register CUSTOM_MGMT_AKS_PREVIEW @@ -4266,6 +4290,30 @@ def test_set_up_api_server_access_profile(self): ) self.assertEqual(dec_mc_3, ground_truth_mc_3) + dec_4 = AKSPreviewManagedClusterCreateDecorator( + self.cmd, + self.client, + { + "apiserver_subnet_id": apiserver_subnet_id, + "vnet_subnet_id": vnet_subnet_id, + "sku": "automatic", + }, + CUSTOM_MGMT_AKS_PREVIEW, + ) + mc_4 = self.models.ManagedCluster(location="test_location") + dec_4.context.attach_mc(mc_4) + dec_mc_4 = dec_4.set_up_api_server_access_profile(mc_4) + ground_truth_api_server_access_profile_4 = ( + self.models.ManagedClusterAPIServerAccessProfile( + subnet_id=apiserver_subnet_id, + ) + ) + ground_truth_mc_4 = self.models.ManagedCluster( + location="test_location", + api_server_access_profile=ground_truth_api_server_access_profile_4, + ) + self.assertEqual(dec_mc_4, ground_truth_mc_4) + def test_build_gitops_addon_profile(self): # default dec_1 = AKSPreviewManagedClusterCreateDecorator( diff --git a/src/aks-preview/setup.py b/src/aks-preview/setup.py index 22cbea031b8..736c4785c8d 100644 --- a/src/aks-preview/setup.py +++ b/src/aks-preview/setup.py @@ -9,7 +9,7 @@ from setuptools import setup, find_packages -VERSION = "13.0.0b2" +VERSION = "13.0.0b3" CLASSIFIERS = [ "Development Status :: 4 - Beta",