Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AKS] Add --network-dataplane to az aks update command #6446

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
++++++

* Add `--network-dataplane` to the `az aks update` command.

0.5.149
+++++++
* `az aks addon update`: Fix unexpected error 'Addon "web_application_routing" is not enabled in this cluster' when trying to update the web app routing addon for an managed cluster that already has it enabled.
Expand Down
6 changes: 6 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,12 @@
long-summary: |
Used to control the mode the network plugin should operate in. For example, "overlay" used with
--network-plugin=azure will use an overlay network (non-VNET IPs) for pods in the cluster.
- name: --network-dataplane
type: string
short-summary: The network dataplane to use.
long-summary: |
Network dataplane used in the Kubernetes cluster.
Specify "azure" to use the Azure dataplane (default) or "cilium" to enable Cilium dataplane.
- name: --disk-driver-version
type: string
short-summary: Specify AzureDisk CSI Driver version.
Expand Down
1 change: 1 addition & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ def load_arguments(self, _):
c.argument('nrg_lockdown_restriction_level', arg_type=get_enum_type(nrg_lockdown_restriction_levels))
c.argument('nat_gateway_managed_outbound_ip_count', type=int, validator=validate_nat_gateway_managed_outbound_ip_count)
c.argument('nat_gateway_idle_timeout', type=int, validator=validate_nat_gateway_idle_timeout)
c.argument('network_dataplane', arg_type=get_enum_type(network_dataplanes))
c.argument('kube_proxy_config')
c.argument('auto_upgrade_channel', arg_type=get_enum_type(auto_upgrade_channels))
c.argument('node_os_upgrade_channel', arg_type=get_enum_type(node_os_upgrade_channels))
Expand Down
1 change: 1 addition & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ def aks_update(
load_balancer_managed_outbound_ipv6_count=None,
outbound_type=None,
network_plugin_mode=None,
network_dataplane=None,
pod_cidr=None,
enable_pod_security_policy=False,
disable_pod_security_policy=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3028,6 +3028,10 @@ def update_network_plugin_settings(self, mc: ManagedCluster) -> ManagedCluster:
if network_plugin_mode:
mc.network_profile.network_plugin_mode = network_plugin_mode

network_dataplane = self.context.get_network_dataplane()
if network_dataplane:
mc.network_profile.network_dataplane = network_dataplane

pod_cidr = self.context.get_pod_cidr()
if pod_cidr:
mc.network_profile.pod_cidr = pod_cidr
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4441,6 +4441,45 @@ def test_aks_azure_cni_overlay_migration(self, resource_group, resource_group_lo
self.cmd(
'aks delete -g {resource_group} -n {name} --yes --no-wait', checks=[self.is_empty()])

@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='eastus', preserve_default_location=True)
def test_aks_migrate_cluster_to_cilium_dataplane(self, resource_group, resource_group_location):
_, create_version = self._get_versions(resource_group_location)
aks_name = self.create_random_name('cliakstest', 16)
self.kwargs.update({
'resource_group': resource_group,
'name': aks_name,
'location': resource_group_location,
'k8s_version': create_version,
'ssh_key_value': self.generate_ssh_keys(),
})

# create with Azure CNI overlay
create_cmd = 'aks create --resource-group={resource_group} --name={name} --location={location} ' \
'--network-plugin azure --ssh-key-value={ssh_key_value} --kubernetes-version {k8s_version} ' \
'--network-plugin-mode=overlay'
self.cmd(create_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.check('networkProfile.networkPlugin', 'azure'),
self.check('networkProfile.networkPluginMode', 'overlay'),
self.check('networkProfile.networkDataplane', 'azure'),
])

# update to enable cilium dataplane
update_cmd = 'aks update -g {resource_group} -n {name} --network-dataplane=cilium'

self.cmd(update_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.check('networkProfile.networkPlugin', 'azure'),
self.check('networkProfile.networkPluginMode', 'overlay'),
self.check('networkProfile.networkDataplane', 'cilium'),
self.check('networkProfile.networkPolicy', 'cilium'),
])

# delete
self.cmd(
'aks delete -g {resource_group} -n {name} --yes --no-wait', checks=[self.is_empty()])

@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='centraluseuap', preserve_default_location=True)
def test_aks_create_or_update_with_load_balancer_backend_pool_type(self, resource_group, resource_group_location):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5041,18 +5041,21 @@ def test_update_network_plugin_settings(self):

self.assertEqual(dec_mc_3, ground_truth_mc_3)

# test no updates made with empty network plugin settings
# test update network dataplane
dec_4 = AKSPreviewManagedClusterUpdateDecorator(
self.cmd,
self.client,
{},
{
"network_dataplane": "cilium",
},
CUSTOM_MGMT_AKS_PREVIEW,
)
mc_4 = self.models.ManagedCluster(
location="test_location",
network_profile=self.models.ContainerServiceNetworkProfile(
network_plugin="azure",
network_plugin_mode="overlay",
network_dataplane="cilium",
pod_cidr="100.64.0.0/16",
service_cidr="192.168.0.0/16"
),
Expand All @@ -5069,13 +5072,49 @@ def test_update_network_plugin_settings(self):
network_profile=self.models.ContainerServiceNetworkProfile(
network_plugin="azure",
network_plugin_mode="overlay",
network_dataplane="cilium",
pod_cidr="100.64.0.0/16",
service_cidr="192.168.0.0/16",
),
)

self.assertEqual(dec_mc_4, ground_truth_mc_4)

# test no updates made with empty network plugin settings
dec_5 = AKSPreviewManagedClusterUpdateDecorator(
self.cmd,
self.client,
{},
CUSTOM_MGMT_AKS_PREVIEW,
)
mc_5 = self.models.ManagedCluster(
location="test_location",
network_profile=self.models.ContainerServiceNetworkProfile(
network_plugin="azure",
network_plugin_mode="overlay",
pod_cidr="100.64.0.0/16",
service_cidr="192.168.0.0/16"
),
)

dec_5.context.attach_mc(mc_5)
# fail on passing the wrong mc object
with self.assertRaises(CLIInternalError):
dec_5.update_network_plugin_settings(None)
dec_mc_5 = dec_5.update_network_plugin_settings(mc_5)

ground_truth_mc_5 = self.models.ManagedCluster(
location="test_location",
network_profile=self.models.ContainerServiceNetworkProfile(
network_plugin="azure",
network_plugin_mode="overlay",
pod_cidr="100.64.0.0/16",
service_cidr="192.168.0.0/16",
),
)

self.assertEqual(dec_mc_5, ground_truth_mc_5)

def test_update_api_server_access_profile(self):
dec_1 = AKSPreviewManagedClusterUpdateDecorator(
self.cmd,
Expand Down