Skip to content

Commit

Permalink
chore: do not use network_plugin default from sdk (#7766)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-lloyd committed Jul 10, 2024
1 parent 8977f76 commit 9be8cea
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2968,6 +2968,17 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
mc = super().set_up_network_profile(mc)
network_profile = mc.network_profile

# network_plugin is typically defaulted to kubenet. AKS-RP is moving
# away from specifying this default in the API and making it based
# on the k8s version being used. The CLI should not be responsible
# for setting default values and should pass properties as empty
# unless specified by the user.
if (
network_profile.network_plugin is not None and
self.context.raw_param.get("network_plugin") is None
):
network_profile.network_plugin = None

# set up pod_cidrs, service_cidrs and ip_families
(
pod_cidrs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6117,6 +6117,7 @@ def test_aks_create_with_pod_identity_enabled(
# create
create_cmd = (
"aks create --resource-group={resource_group} --name={name} --location={location} "
"--network-plugin kubenet "
"--enable-managed-identity "
"--enable-pod-identity --enable-pod-identity-with-kubenet "
"--ssh-key-value={ssh_key_value} "
Expand Down Expand Up @@ -6417,6 +6418,7 @@ def test_aks_pod_identity_usage(self, resource_group, resource_group_location):
# create
create_cmd = (
"aks create --resource-group={resource_group} --name={name} --location={location} "
"--network-plugin kubenet "
"--enable-managed-identity "
"--enable-pod-identity --enable-pod-identity-with-kubenet "
"--ssh-key-value={ssh_key_value} "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4168,7 +4168,7 @@ def test_set_up_agentpool_profile(self):
ground_truth_mc_1.agent_pool_profiles = [ground_truth_agentpool_profile_1]
self.assertEqual(dec_mc_1, ground_truth_mc_1)

def test_set_up_network_profile(self):
def test_set_up_network_profile_preview(self):
# custom value
dec_1 = AKSPreviewManagedClusterCreateDecorator(
self.cmd,
Expand Down Expand Up @@ -4214,6 +4214,7 @@ def test_set_up_network_profile(self):
network_profile_1.ip_families = ["IPv4", "IPv6"]
network_profile_1.pod_cidrs = ["10.246.0.0/16", "2001:abcd::/64"]
network_profile_1.service_cidrs = ["10.0.0.0/16", "2001:ffff::/108"]
network_profile_1.network_plugin = None

load_balancer_profile_1 = self.models.load_balancer_models.ManagedClusterLoadBalancerProfile(
managed_outbound_i_ps=self.models.load_balancer_models.ManagedClusterLoadBalancerProfileManagedOutboundIPs(
Expand All @@ -4227,6 +4228,36 @@ def test_set_up_network_profile(self):
)
self.assertEqual(dec_mc_1, ground_truth_mc_1)

# custom value
dec_2 = AKSPreviewManagedClusterCreateDecorator(
self.cmd,
self.client,
{
"network_plugin": "azure",
},
CUSTOM_MGMT_AKS_PREVIEW,
)
mc_2 = self.models.ManagedCluster(location="test_location")
dec_2.context.attach_mc(mc_2)
dec_mc_2 = dec_2.set_up_network_profile(mc_2)

network_profile_2 = self.models.ContainerServiceNetworkProfile()
# TODO: remove this temp fix once aks-preview's dependency on core azure-cli is updated to 2.26.0
for attr_name, attr_value in vars(network_profile_2).items():
if (
not attr_name.startswith("_")
and attr_name not in ["additional_properties", "outbound_type"]
and attr_value is not None
):
setattr(network_profile_2, attr_name, None)
network_profile_2.network_plugin = "azure"
network_profile_2.load_balancer_sku = CONST_LOAD_BALANCER_SKU_STANDARD

ground_truth_mc_2 = self.models.ManagedCluster(
location="test_location", network_profile=network_profile_2
)
self.assertEqual(dec_mc_2, ground_truth_mc_2)

def test_set_up_api_server_access_profile(self):
dec_1 = AKSPreviewManagedClusterCreateDecorator(
self.cmd,
Expand Down Expand Up @@ -5359,6 +5390,7 @@ def test_construct_mc_profile_preview(self):
)
network_profile_1 = self.models.ContainerServiceNetworkProfile(
load_balancer_sku="standard",
network_plugin=None,
)
identity_1 = self.models.ManagedClusterIdentity(type="SystemAssigned")
storage_profile_1 = self.models.ManagedClusterStorageProfile(
Expand Down

0 comments on commit 9be8cea

Please sign in to comment.