Skip to content

Commit 6073be7

Browse files
authored
[AKS] az aks create/update: Add support for feature Advanced Container Networking Services (#30208)
1 parent 1d062ee commit 6073be7

10 files changed

Lines changed: 6822 additions & 0 deletions

src/azure-cli/azure/cli/command_modules/acs/_help.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,15 @@
541541
- name: --enable-vtpm
542542
type: bool
543543
short-summary: Enable vTPM on all node pools in the cluster. Must use VMSS agent pool type.
544+
- name: --enable-acns
545+
type: bool
546+
short-summary: Enable advanced network functionalities on a cluster. Enabling this will incur additional costs. For non-cilium clusters, acns security will be disabled by default until further notice.
547+
- name: --disable-acns-observability
548+
type: bool
549+
short-summary: Used to disable advanced networking observability features on a clusters when enabling advanced networking features with "--enable-acns".
550+
- name: --disable-acns-security
551+
type: bool
552+
short-summary: Used to disable advanced networking security features on a clusters when enabling advanced networking features with "--enable-acns".
544553
545554
examples:
546555
- name: Create a Kubernetes cluster with an existing SSH public key.
@@ -943,6 +952,18 @@
943952
- name: --disable-cost-analysis
944953
type: bool
945954
short-summary: Disable exporting Kubernetes Namespace and Deployment details to the Cost Analysis views in the Azure portal.
955+
- name: --enable-acns
956+
type: bool
957+
short-summary: Enable advanced network functionalities on a cluster. Enabling this will incur additional costs. For non-cilium clusters, acns security will be disabled by default until further notice.
958+
- name: --disable-acns
959+
type: bool
960+
short-summary: Disable all advanced networking functionalities on a cluster.
961+
- name: --disable-acns-observability
962+
type: bool
963+
short-summary: Used to disable advanced networking observability features on a clusters when enabling advanced networking features with "--enable-acns".
964+
- name: --disable-acns-security
965+
type: bool
966+
short-summary: Used to disable advanced networking security features on a clusters when enabling advanced networking features with "--enable-acns".
946967
947968
examples:
948969
- name: Reconcile the cluster back to its current state.

src/azure-cli/azure/cli/command_modules/acs/_params.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ def load_arguments(self, _):
464464
c.argument('enable_cost_analysis', action='store_true')
465465
c.argument('enable_vtpm', action="store_true")
466466
c.argument('enable_secure_boot', action="store_true")
467+
# advanced networking
468+
c.argument('enable_acns', action='store_true')
469+
c.argument('disable_acns_observability', action='store_true')
470+
c.argument('disable_acns_security', action='store_true')
467471

468472
with self.argument_context('aks update') as c:
469473
# managed cluster paramerters
@@ -487,6 +491,11 @@ def load_arguments(self, _):
487491
help="Comma-separated list of key=value pairs for configuring cluster autoscaler. Pass an empty string to clear the profile.")
488492
c.argument('tier', arg_type=get_enum_type(sku_tiers), validator=validate_sku_tier)
489493
c.argument('api_server_authorized_ip_ranges', validator=validate_ip_ranges)
494+
# advanced networking
495+
c.argument('enable_acns', action='store_true')
496+
c.argument('disable_acns', action='store_true')
497+
c.argument('disable_acns_observability', action='store_true')
498+
c.argument('disable_acns_security', action='store_true')
490499
# private cluster parameters
491500
c.argument('enable_public_fqdn', action='store_true')
492501
c.argument('disable_public_fqdn', action='store_true')

src/azure-cli/azure/cli/command_modules/acs/custom.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ def aks_create(
562562
image_cleaner_interval_hours=None,
563563
enable_keda=False,
564564
enable_vpa=False,
565+
# advanced networking
566+
enable_acns=None,
567+
disable_acns_observability=None,
568+
disable_acns_security=None,
565569
# addons
566570
enable_addons=None,
567571
workspace_resource_id=None,
@@ -756,6 +760,11 @@ def aks_update(
756760
enable_force_upgrade=False,
757761
disable_force_upgrade=False,
758762
upgrade_override_until=None,
763+
# advanced networking
764+
disable_acns=None,
765+
enable_acns=None,
766+
disable_acns_observability=None,
767+
disable_acns_security=None,
759768
# addons
760769
enable_secret_rotation=False,
761770
disable_secret_rotation=False,

src/azure-cli/azure/cli/command_modules/acs/linter_exclusions.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ aks create:
7070
enable_high_log_scale_mode:
7171
rule_exclusions:
7272
- option_length_too_long
73+
disable_acns_observability:
74+
rule_exclusions:
75+
- option_length_too_long
7376

7477
aks enable-addons:
7578
parameters:
@@ -162,6 +165,9 @@ aks update:
162165
enable_high_log_scale_mode:
163166
rule_exclusions:
164167
- option_length_too_long
168+
disable_acns_observability:
169+
rule_exclusions:
170+
- option_length_too_long
165171
aks nodepool add:
166172
parameters:
167173
disable_windows_outbound_nat:

src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,6 +2360,54 @@ def get_network_dataplane(self) -> Union[str, None]:
23602360
"""
23612361
return self.raw_param.get("network_dataplane")
23622362

2363+
def get_acns_enablement(self) -> Tuple[
2364+
Union[bool, None],
2365+
Union[bool, None],
2366+
Union[bool, None],
2367+
]:
2368+
"""Get the enablement of acns
2369+
2370+
:return: Tuple of 3 elements which can be bool or None
2371+
"""
2372+
enable_acns = self.raw_param.get("enable_acns")
2373+
disable_acns = self.raw_param.get("disable_acns")
2374+
if enable_acns is None and disable_acns is None:
2375+
return None, None, None
2376+
if enable_acns and disable_acns:
2377+
raise MutuallyExclusiveArgumentError(
2378+
"Cannot specify --enable-acns and "
2379+
"--disable-acns at the same time."
2380+
)
2381+
enable_acns = bool(enable_acns) if enable_acns is not None else False
2382+
disable_acns = bool(disable_acns) if disable_acns is not None else False
2383+
acns = enable_acns or not disable_acns
2384+
acns_observability = self.get_acns_observability()
2385+
acns_security = self.get_acns_security()
2386+
if acns and (acns_observability is False and acns_security is False):
2387+
raise MutuallyExclusiveArgumentError(
2388+
"Cannot disable both observability and security when enabling ACNS. "
2389+
"Please enable at least one of them or disable ACNS with --disable-acns."
2390+
)
2391+
if not acns and (acns_observability is not None or acns_security is not None):
2392+
raise MutuallyExclusiveArgumentError(
2393+
"--disable-acns does not use any additional acns arguments."
2394+
)
2395+
return acns, acns_observability, acns_security
2396+
2397+
def get_acns_observability(self) -> Union[bool, None]:
2398+
"""Get the enablement of acns observability
2399+
2400+
:return: bool or None"""
2401+
disable_acns_observability = self.raw_param.get("disable_acns_observability")
2402+
return not bool(disable_acns_observability) if disable_acns_observability is not None else None
2403+
2404+
def get_acns_security(self) -> Union[bool, None]:
2405+
"""Get the enablement of acns security
2406+
2407+
:return: bool or None"""
2408+
disable_acns_security = self.raw_param.get("disable_acns_security")
2409+
return not bool(disable_acns_security) if disable_acns_security is not None else None
2410+
23632411
def _get_pod_cidr_and_service_cidr_and_dns_service_ip_and_docker_bridge_address_and_network_policy(
23642412
self, enable_validation: bool = False
23652413
) -> Tuple[
@@ -5651,6 +5699,20 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
56515699

56525700
network_dataplane = self.context.get_network_dataplane()
56535701

5702+
(acns_enabled, acns_observability, acns_security) = self.context.get_acns_enablement()
5703+
if acns_enabled is not None:
5704+
acns = self.models.AdvancedNetworking(
5705+
enabled=acns_enabled,
5706+
)
5707+
if acns_observability is not None:
5708+
acns.observability = self.models.AdvancedNetworkingObservability(
5709+
enabled=acns_observability,
5710+
)
5711+
if acns_security is not None:
5712+
acns.security = self.models.AdvancedNetworkingSecurity(
5713+
enabled=acns_security,
5714+
)
5715+
56545716
if any(
56555717
[
56565718
network_plugin,
@@ -5710,6 +5772,8 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
57105772
load_balancer_sku = self.context.get_load_balancer_sku()
57115773
if load_balancer_sku != CONST_LOAD_BALANCER_SKU_BASIC:
57125774
network_profile.nat_gateway_profile = nat_gateway_profile
5775+
if acns_enabled is not None:
5776+
network_profile.advanced_networking = acns
57135777
mc.network_profile = network_profile
57145778
return mc
57155779

@@ -7319,6 +7383,29 @@ def update_network_plugin_settings(self, mc: ManagedCluster) -> ManagedCluster:
73197383

73207384
return mc
73217385

7386+
def update_network_profile_advanced_networking(self, mc: ManagedCluster) -> ManagedCluster:
7387+
"""Update advanced networking settings of network profile for the ManagedCluster object.
7388+
7389+
:return: the ManagedCluster object
7390+
"""
7391+
self._ensure_mc(mc)
7392+
(acns_enabled, acns_observability, acns_security) = self.context.get_acns_enablement()
7393+
if acns_enabled is not None:
7394+
acns = self.models.AdvancedNetworking(
7395+
enabled=acns_enabled,
7396+
)
7397+
if acns_observability is not None:
7398+
acns.observability = self.models.AdvancedNetworkingObservability(
7399+
enabled=acns_observability,
7400+
)
7401+
if acns_security is not None:
7402+
acns.security = self.models.AdvancedNetworkingSecurity(
7403+
enabled=acns_security,
7404+
)
7405+
if acns_enabled is not None:
7406+
mc.network_profile.advanced_networking = acns
7407+
return mc
7408+
73227409
def update_http_proxy_config(self, mc: ManagedCluster) -> ManagedCluster:
73237410
"""Set up http proxy config for the ManagedCluster object.
73247411
@@ -8242,6 +8329,8 @@ def update_mc_profile_default(self) -> ManagedCluster:
82428329
mc = self.update_windows_profile(mc)
82438330
# update network plugin settings
82448331
mc = self.update_network_plugin_settings(mc)
8332+
# update network profile with acns
8333+
mc = self.update_network_profile_advanced_networking(mc)
82458334
# update aad profile
82468335
mc = self.update_aad_profile(mc)
82478336
# update oidc issuer profile

0 commit comments

Comments
 (0)