Skip to content

Commit 158ee74

Browse files
[AKS] az aks create/update Add support for ACNS performance (#33018)
1 parent 7cc90a5 commit 158ee74

File tree

11 files changed

+4616
-360
lines changed

11 files changed

+4616
-360
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@
144144
CONST_NETWORK_POD_IP_ALLOCATION_MODE_DYNAMIC_INDIVIDUAL = "DynamicIndividual"
145145
CONST_NETWORK_POD_IP_ALLOCATION_MODE_STATIC_BLOCK = "StaticBlock"
146146

147+
# advanced container networking services (ACNS) datapath acceleration mode
148+
CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH = "BpfVeth"
149+
CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE = "None"
150+
147151
# consts for addons
148152
# http application routing
149153
CONST_HTTP_APPLICATION_ROUTING_ADDON_NAME = "httpApplicationRouting"

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,9 @@
591591
- name: --enable-container-network-logs
592592
type: bool
593593
short-summary: Enable container network log collection functionalities on a cluster. Automatically enables --enable-high-log-scale-mode.
594+
- name: --acns-datapath-acceleration-mode
595+
type: string
596+
short-summary: Set the datapath acceleration mode for Azure Container Networking Solution (ACNS) Performance. Valid values are 'BpfVeth' and 'None'.
594597
- name: --acns-transit-encryption-type
595598
type: string
596599
short-summary: Set transit encryption type for ACNS security.
@@ -1102,6 +1105,9 @@
11021105
- name: --disable-container-network-logs
11031106
type: bool
11041107
short-summary: Disable container network log collection functionalities on a cluster.
1108+
- name: --acns-datapath-acceleration-mode
1109+
type: string
1110+
short-summary: Set the datapath acceleration mode for Azure Container Networking Solution (ACNS) Performance. Valid values are 'BpfVeth' and 'None'.
11051111
- name: --acns-transit-encryption-type
11061112
type: string
11071113
short-summary: Set transit encryption type for ACNS security.

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
CONST_NETWORK_PLUGIN_MODE_OVERLAY, CONST_NETWORK_PLUGIN_NONE,
2626
CONST_NETWORK_POD_IP_ALLOCATION_MODE_DYNAMIC_INDIVIDUAL,
2727
CONST_NETWORK_POD_IP_ALLOCATION_MODE_STATIC_BLOCK,
28+
CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH, CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE,
2829
CONST_NODE_IMAGE_UPGRADE_CHANNEL, CONST_NONE_UPGRADE_CHANNEL,
2930
CONST_NODE_OS_CHANNEL_NODE_IMAGE,
3031
CONST_NODE_OS_CHANNEL_NONE,
@@ -370,6 +371,12 @@
370371
CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION,
371372
]
372373

374+
# consts for acns datapath acceleration mode
375+
acns_datapath_acceleration_modes = [
376+
CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH,
377+
CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE
378+
]
379+
373380

374381
def load_arguments(self, _):
375382
acr_arg_type = CLIArgumentType(metavar='ACR_NAME_OR_RESOURCE_ID')
@@ -612,6 +619,11 @@ def load_arguments(self, _):
612619
c.argument('disable_acns_security', action='store_true')
613620
c.argument("acns_advanced_networkpolicies", arg_type=get_enum_type(advanced_networkpolicies))
614621
c.argument('enable_container_network_logs', action='store_true')
622+
c.argument(
623+
"acns_datapath_acceleration_mode",
624+
arg_type=get_enum_type(acns_datapath_acceleration_modes),
625+
help="Set the datapath acceleration mode for Azure Container Networking Solution (ACNS). Valid values are 'BpfVeth' and 'None'."
626+
)
615627
c.argument('acns_transit_encryption_type', arg_type=get_enum_type(transit_encryption_types))
616628
c.argument("if_match")
617629
c.argument("if_none_match")
@@ -672,6 +684,11 @@ def load_arguments(self, _):
672684
c.argument("acns_advanced_networkpolicies", arg_type=get_enum_type(advanced_networkpolicies))
673685
c.argument('enable_container_network_logs', action='store_true')
674686
c.argument('disable_container_network_logs', action='store_true')
687+
c.argument(
688+
"acns_datapath_acceleration_mode",
689+
arg_type=get_enum_type(acns_datapath_acceleration_modes),
690+
help="Set the datapath acceleration mode for Azure Container Networking Solution (ACNS). Valid values are 'BpfVeth' and 'None'."
691+
)
675692
c.argument('acns_transit_encryption_type', arg_type=get_enum_type(transit_encryption_types))
676693
# private cluster parameters
677694
c.argument('enable_apiserver_vnet_integration', action='store_true')

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ def aks_create(
935935
disable_acns_security=None,
936936
acns_advanced_networkpolicies=None,
937937
enable_container_network_logs=None,
938+
acns_datapath_acceleration_mode=None,
938939
acns_transit_encryption_type=None,
939940
# network isoalted cluster
940941
bootstrap_artifact_source=CONST_ARTIFACT_SOURCE_DIRECT,
@@ -1165,6 +1166,7 @@ def aks_update(
11651166
acns_advanced_networkpolicies=None,
11661167
enable_container_network_logs=None,
11671168
disable_container_network_logs=None,
1169+
acns_datapath_acceleration_mode=None,
11681170
acns_transit_encryption_type=None,
11691171
# network isoalted cluster
11701172
bootstrap_artifact_source=None,
@@ -1408,7 +1410,7 @@ def _update_upgrade_settings(cmd, instance,
14081410
f"{upgrade_override_until} is not a valid datatime format."
14091411
)
14101412
elif force_upgrade:
1411-
default_extended_until = datetime.datetime.now(datetime.UTC) + datetime.timedelta(days=3)
1413+
default_extended_until = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=3)
14121414
if existing_until is None or existing_until.timestamp() < default_extended_until.timestamp():
14131415
instance.upgrade_settings.override_settings.until = default_extended_until
14141416
return instance

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
@@ -76,6 +76,9 @@ aks create:
7676
acns_advanced_networkpolicies:
7777
rule_exclusions:
7878
- option_length_too_long
79+
acns_datapath_acceleration_mode:
80+
rule_exclusions:
81+
- option_length_too_long
7982
acns_transit_encryption_type:
8083
rule_exclusions:
8184
- option_length_too_long
@@ -194,6 +197,9 @@ aks update:
194197
acns_advanced_networkpolicies:
195198
rule_exclusions:
196199
- option_length_too_long
200+
acns_datapath_acceleration_mode:
201+
rule_exclusions:
202+
- option_length_too_long
197203
acns_transit_encryption_type:
198204
rule_exclusions:
199205
- option_length_too_long

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

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
CONST_NONE_UPGRADE_CHANNEL,
4949
CONST_AVAILABILITY_SET,
5050
CONST_VIRTUAL_MACHINES,
51+
CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH,
52+
CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE
5153
)
5254
from azure.cli.command_modules.acs.azurecontainerstorage._consts import (
5355
CONST_ACSTOR_EXT_INSTALLATION_NAME,
@@ -2531,19 +2533,20 @@ def get_network_dataplane(self) -> Union[str, None]:
25312533
"""
25322534
return self.raw_param.get("network_dataplane")
25332535

2534-
def get_acns_enablement(self) -> Tuple[
2536+
def get_acns_enablement_with_perf(self) -> Tuple[
25352537
Union[bool, None],
25362538
Union[bool, None],
25372539
Union[bool, None],
2540+
Union[bool, None]
25382541
]:
25392542
"""Get the enablement of acns
25402543
2541-
:return: Tuple of 3 elements which can be bool or None
2544+
:return: Tuple of 4 elements which can be bool or None
25422545
"""
25432546
enable_acns = self.raw_param.get("enable_acns")
25442547
disable_acns = self.raw_param.get("disable_acns")
25452548
if enable_acns is None and disable_acns is None:
2546-
return None, None, None
2549+
return None, None, None, None
25472550
if enable_acns and disable_acns:
25482551
raise MutuallyExclusiveArgumentError(
25492552
"Cannot specify --enable-acns and "
@@ -2553,17 +2556,22 @@ def get_acns_enablement(self) -> Tuple[
25532556
disable_acns = bool(disable_acns) if disable_acns is not None else False
25542557
acns = enable_acns or not disable_acns
25552558
acns_observability = self.get_acns_observability()
2559+
acns_datapath_acceleration_mode = self.get_acns_datapath_acceleration_mode()
2560+
acns_perf_enabled = None
2561+
if acns_datapath_acceleration_mode is not None:
2562+
acns_perf_enabled = acns_datapath_acceleration_mode == CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH
25562563
acns_security = self.get_acns_security()
2557-
if acns and (acns_observability is False and acns_security is False):
2564+
if acns and (acns_observability is False and acns_security is False and acns_perf_enabled is not True):
25582565
raise MutuallyExclusiveArgumentError(
2559-
"Cannot disable both observability and security when enabling ACNS. "
2566+
"Cannot disable observability, security, and performance acceleration when enabling ACNS. "
25602567
"Please enable at least one of them or disable ACNS with --disable-acns."
25612568
)
2562-
if not acns and (acns_observability is not None or acns_security is not None):
2569+
if not acns and (acns_observability is not None or acns_security is not None or
2570+
acns_datapath_acceleration_mode is not None):
25632571
raise MutuallyExclusiveArgumentError(
25642572
"--disable-acns does not use any additional acns arguments."
25652573
)
2566-
return acns, acns_observability, acns_security
2574+
return acns, acns_observability, acns_security, acns_perf_enabled
25672575

25682576
def get_acns_observability(self) -> Union[bool, None]:
25692577
"""Get the enablement of acns observability
@@ -2579,6 +2587,28 @@ def get_acns_security(self) -> Union[bool, None]:
25792587
disable_acns_security = self.raw_param.get("disable_acns_security")
25802588
return not bool(disable_acns_security) if disable_acns_security is not None else None
25812589

2590+
def get_acns_datapath_acceleration_mode(self) -> Union[str, None]:
2591+
"""Get the value of acns_datapath_acceleration_mode
2592+
2593+
:return: str or None
2594+
"""
2595+
disable_acns = self.raw_param.get("disable_acns")
2596+
enable_acns = self.raw_param.get("enable_acns")
2597+
acns_datapath_acceleration_mode = self.raw_param.get("acns_datapath_acceleration_mode")
2598+
if acns_datapath_acceleration_mode is not None and \
2599+
acns_datapath_acceleration_mode != CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE:
2600+
if disable_acns:
2601+
raise MutuallyExclusiveArgumentError(
2602+
"--disable-acns cannot be used with --acns-performance-acceleration-mode."
2603+
)
2604+
# Require explicit ACNS enablement when specifying a datapath acceleration mode on create
2605+
if self.decorator_mode == DecoratorMode.CREATE and not enable_acns:
2606+
raise ArgumentUsageError(
2607+
"--acns-datapath-acceleration-mode can only be used when ACNS is enabled. "
2608+
"Please specify --enable-acns."
2609+
)
2610+
return acns_datapath_acceleration_mode
2611+
25822612
def get_acns_advanced_networkpolicies(self) -> Union[str, None]:
25832613
"""Get the value of acns_advanced_networkpolicies
25842614
:return: str or None
@@ -2842,7 +2872,8 @@ def get_addon_consts(self) -> Dict[str, str]:
28422872
CONST_MONITORING_USING_AAD_MSI_AUTH,
28432873
CONST_OPEN_SERVICE_MESH_ADDON_NAME, CONST_ROTATION_POLL_INTERVAL,
28442874
CONST_SECRET_ROTATION_ENABLED, CONST_VIRTUAL_NODE_ADDON_NAME,
2845-
CONST_VIRTUAL_NODE_SUBNET_NAME)
2875+
CONST_VIRTUAL_NODE_SUBNET_NAME
2876+
)
28462877

28472878
addon_consts = {}
28482879
addon_consts["ADDONS"] = ADDONS
@@ -6380,8 +6411,8 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
63806411

63816412
network_dataplane = self.context.get_network_dataplane()
63826413

6383-
(acns_enabled, acns_observability, acns_security) = self.context.get_acns_enablement()
63846414
acns_advanced_networkpolicies = self.context.get_acns_advanced_networkpolicies()
6415+
(acns_enabled, acns_observability, acns_security, acns_perf_enabled) = self.context.get_acns_enablement_with_perf()
63856416
acns_transit_encryption = self.context.get_acns_transit_encryption_type()
63866417
if acns_enabled is not None:
63876418
acns = self.models.AdvancedNetworking(
@@ -6402,6 +6433,10 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
64026433
)
64036434
else:
64046435
acns.security.advanced_network_policies = acns_advanced_networkpolicies
6436+
if acns_perf_enabled is not None:
6437+
if acns.performance is None:
6438+
acns.performance = self.models.AdvancedNetworkingPerformance()
6439+
acns.performance.acceleration_mode = self.context.get_acns_datapath_acceleration_mode()
64056440
if acns_transit_encryption is not None:
64066441
if acns.security is None:
64076442
acns.security = self.models.AdvancedNetworkingSecurity()
@@ -8312,8 +8347,8 @@ def update_network_profile_advanced_networking(self, mc: ManagedCluster) -> Mana
83128347
:return: the ManagedCluster object
83138348
"""
83148349
self._ensure_mc(mc)
8315-
(acns_enabled, acns_observability, acns_security) = self.context.get_acns_enablement()
83168350
acns_advanced_networkpolicies = self.context.get_acns_advanced_networkpolicies()
8351+
(acns_enabled, acns_observability, acns_security, acns_perf_enabled) = self.context.get_acns_enablement_with_perf()
83178352
acns_transit_encryption = self.context.get_acns_transit_encryption_type()
83188353
if acns_enabled is not None:
83198354
acns = self.models.AdvancedNetworking(
@@ -8334,6 +8369,18 @@ def update_network_profile_advanced_networking(self, mc: ManagedCluster) -> Mana
83348369
)
83358370
else:
83368371
acns.security.advanced_network_policies = acns_advanced_networkpolicies
8372+
if acns_perf_enabled is not None:
8373+
acns.performance = self.models.AdvancedNetworkingPerformance(
8374+
acceleration_mode=self.context.get_acns_datapath_acceleration_mode(),
8375+
)
8376+
elif not acns_enabled:
8377+
acns.performance = self.models.AdvancedNetworkingPerformance(
8378+
acceleration_mode=CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE,
8379+
)
8380+
elif mc.network_profile.advanced_networking is not None:
8381+
acns.performance = mc.network_profile.advanced_networking.performance
8382+
8383+
if acns_enabled is not None:
83378384
if acns_transit_encryption is not None:
83388385
if acns.security is None:
83398386
acns.security = self.models.AdvancedNetworkingSecurity()

0 commit comments

Comments
 (0)