Skip to content

Commit 3206ff8

Browse files
committed
[AKS] az aks create/update: Add support for ACNS transit encryption
Add `--acns-transit-encryption-type` parameter to `az aks create` and `az aks update` commands. This allows users to configure pod-to-pod transit encryption on Cilium-based AKS clusters as part of the ACNS security feature suite. Bump azure-mgmt-containerservice SDK from 40.0.0 to 41.0.0 which includes the AdvancedNetworkingSecurityTransitEncryption model. Signed-off-by: Quang Nguyen <nguyenquang@microsoft.com>
1 parent ecf19d1 commit 3206ff8

11 files changed

Lines changed: 2737 additions & 4 deletions

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@
246246
CONST_NODE_PROVISIONING_DEFAULT_POOLS_NONE = "None"
247247
CONST_NODE_PROVISIONING_DEFAULT_POOLS_AUTO = "Auto"
248248

249+
# consts for acns transit encryption
250+
CONST_TRANSIT_ENCRYPTION_WIREGUARD = "WireGuard"
251+
CONST_TRANSIT_ENCRYPTION_NONE = "None"
252+
249253

250254
# consts for decorator pattern
251255
class DecoratorMode(Enum):

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@
581581
- name: --disable-acns-security
582582
type: bool
583583
short-summary: Used to disable advanced networking security features on a clusters when enabling advanced networking features with "--enable-acns".
584+
- name: --acns-transit-encryption-type
585+
type: string
586+
short-summary: Set transit encryption type for ACNS security.
587+
long-summary: Configures pod-to-pod encryption for Cilium-based clusters. Once enabled, all traffic between Cilium managed pods will be encrypted when it leaves the node boundary. Valid values are "WireGuard" and "None". This can only be used with "--enable-acns".
584588
- name: --nrg-lockdown-restriction-level
585589
type: string
586590
short-summary: Restriction level on the managed node resource group.
@@ -1070,6 +1074,10 @@
10701074
- name: --disable-acns-security
10711075
type: bool
10721076
short-summary: Used to disable advanced networking security features on a clusters when enabling advanced networking features with "--enable-acns".
1077+
- name: --acns-transit-encryption-type
1078+
type: string
1079+
short-summary: Set transit encryption type for ACNS security.
1080+
long-summary: Configures pod-to-pod encryption for Cilium-based clusters. Once enabled, all traffic between Cilium managed pods will be encrypted when it leaves the node boundary. Valid values are "WireGuard" and "None". This can only be used with "--enable-acns".
10731081
- name: --nrg-lockdown-restriction-level
10741082
type: string
10751083
short-summary: Restriction level on the managed node resource group.

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
CONST_NODE_PROVISIONING_MODE_MANUAL,
6565
CONST_NODE_PROVISIONING_MODE_AUTO,
6666
CONST_NODE_PROVISIONING_DEFAULT_POOLS_NONE,
67-
CONST_NODE_PROVISIONING_DEFAULT_POOLS_AUTO)
67+
CONST_NODE_PROVISIONING_DEFAULT_POOLS_AUTO,
68+
CONST_TRANSIT_ENCRYPTION_WIREGUARD,
69+
CONST_TRANSIT_ENCRYPTION_NONE)
6870
from azure.cli.command_modules.acs.azurecontainerstorage._consts import (
6971
CONST_ACSTOR_ALL,
7072
CONST_DISK_TYPE_EPHEMERAL_VOLUME_ONLY,
@@ -209,6 +211,11 @@
209211
CONST_NODE_PROVISIONING_DEFAULT_POOLS_AUTO,
210212
]
211213

214+
transit_encryption_types = [
215+
CONST_TRANSIT_ENCRYPTION_WIREGUARD,
216+
CONST_TRANSIT_ENCRYPTION_NONE,
217+
]
218+
212219
dev_space_endpoint_types = ['Public', 'Private', 'None']
213220

214221
keyvault_network_access_types = [CONST_AZURE_KEYVAULT_NETWORK_ACCESS_PUBLIC, CONST_AZURE_KEYVAULT_NETWORK_ACCESS_PRIVATE]
@@ -561,6 +568,7 @@ def load_arguments(self, _):
561568
c.argument('enable_acns', action='store_true')
562569
c.argument('disable_acns_observability', action='store_true')
563570
c.argument('disable_acns_security', action='store_true')
571+
c.argument('acns_transit_encryption_type', arg_type=get_enum_type(transit_encryption_types))
564572
c.argument("if_match")
565573
c.argument("if_none_match")
566574
# node provisioning
@@ -617,6 +625,7 @@ def load_arguments(self, _):
617625
c.argument('disable_acns', action='store_true')
618626
c.argument('disable_acns_observability', action='store_true')
619627
c.argument('disable_acns_security', action='store_true')
628+
c.argument('acns_transit_encryption_type', arg_type=get_enum_type(transit_encryption_types))
620629
# private cluster parameters
621630
c.argument('enable_apiserver_vnet_integration', action='store_true')
622631
c.argument('apiserver_subnet_id', validator=validate_apiserver_subnet_id)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ def aks_create(
700700
enable_acns=None,
701701
disable_acns_observability=None,
702702
disable_acns_security=None,
703+
acns_transit_encryption_type=None,
703704
# network isoalted cluster
704705
bootstrap_artifact_source=CONST_ARTIFACT_SOURCE_DIRECT,
705706
bootstrap_container_registry_resource_id=None,
@@ -925,6 +926,7 @@ def aks_update(
925926
enable_acns=None,
926927
disable_acns_observability=None,
927928
disable_acns_security=None,
929+
acns_transit_encryption_type=None,
928930
# network isoalted cluster
929931
bootstrap_artifact_source=None,
930932
bootstrap_container_registry_resource_id=None,

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
@@ -73,6 +73,9 @@ aks create:
7373
disable_acns_observability:
7474
rule_exclusions:
7575
- option_length_too_long
76+
acns_transit_encryption_type:
77+
rule_exclusions:
78+
- option_length_too_long
7679
nrg_lockdown_restriction_level:
7780
rule_exclusions:
7881
- option_length_too_long
@@ -182,6 +185,9 @@ aks update:
182185
disable_acns_observability:
183186
rule_exclusions:
184187
- option_length_too_long
188+
acns_transit_encryption_type:
189+
rule_exclusions:
190+
- option_length_too_long
185191
nrg_lockdown_restriction_level:
186192
rule_exclusions:
187193
- option_length_too_long

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

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2580,6 +2580,32 @@ def get_acns_security(self) -> Union[bool, None]:
25802580
disable_acns_security = self.raw_param.get("disable_acns_security")
25812581
return not bool(disable_acns_security) if disable_acns_security is not None else None
25822582

2583+
def get_acns_transit_encryption_type(self) -> Union[str, None]:
2584+
"""Get the transit encryption type for acns security.
2585+
2586+
:return: str or None
2587+
"""
2588+
acns_transit_encryption = self.raw_param.get("acns_transit_encryption_type")
2589+
if acns_transit_encryption is not None:
2590+
enable_acns = self.raw_param.get("enable_acns")
2591+
disable_acns = self.raw_param.get("disable_acns")
2592+
disable_acns_security = self.raw_param.get("disable_acns_security")
2593+
if disable_acns_security:
2594+
raise MutuallyExclusiveArgumentError(
2595+
"Cannot specify --acns-transit-encryption and "
2596+
"--disable-acns-security at the same time."
2597+
)
2598+
if disable_acns:
2599+
raise MutuallyExclusiveArgumentError(
2600+
"Cannot specify --acns-transit-encryption and "
2601+
"--disable-acns at the same time."
2602+
)
2603+
if self.decorator_mode == DecoratorMode.CREATE and not enable_acns:
2604+
raise MutuallyExclusiveArgumentError(
2605+
"--acns-transit-encryption requires --enable-acns."
2606+
)
2607+
return acns_transit_encryption
2608+
25832609
def _get_pod_cidr_and_service_cidr_and_dns_service_ip_and_docker_bridge_address_and_network_policy(
25842610
self, enable_validation: bool = False
25852611
) -> Tuple[
@@ -6180,6 +6206,7 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
61806206
network_dataplane = self.context.get_network_dataplane()
61816207

61826208
(acns_enabled, acns_observability, acns_security) = self.context.get_acns_enablement()
6209+
acns_transit_encryption = self.context.get_acns_transit_encryption_type()
61836210
if acns_enabled is not None:
61846211
acns = self.models.AdvancedNetworking(
61856212
enabled=acns_enabled,
@@ -6192,6 +6219,12 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
61926219
acns.security = self.models.AdvancedNetworkingSecurity(
61936220
enabled=acns_security,
61946221
)
6222+
if acns_transit_encryption is not None:
6223+
if acns.security is None:
6224+
acns.security = self.models.AdvancedNetworkingSecurity()
6225+
acns.security.transit_encryption = self.models.AdvancedNetworkingSecurityTransitEncryption(
6226+
type=acns_transit_encryption,
6227+
)
61956228

61966229
if any(
61976230
[
@@ -8091,6 +8124,7 @@ def update_network_profile_advanced_networking(self, mc: ManagedCluster) -> Mana
80918124
"""
80928125
self._ensure_mc(mc)
80938126
(acns_enabled, acns_observability, acns_security) = self.context.get_acns_enablement()
8127+
acns_transit_encryption = self.context.get_acns_transit_encryption_type()
80948128
if acns_enabled is not None:
80958129
acns = self.models.AdvancedNetworking(
80968130
enabled=acns_enabled,
@@ -8103,8 +8137,23 @@ def update_network_profile_advanced_networking(self, mc: ManagedCluster) -> Mana
81038137
acns.security = self.models.AdvancedNetworkingSecurity(
81048138
enabled=acns_security,
81058139
)
8106-
if acns_enabled is not None:
8140+
if acns_transit_encryption is not None:
8141+
if acns.security is None:
8142+
acns.security = self.models.AdvancedNetworkingSecurity()
8143+
acns.security.transit_encryption = self.models.AdvancedNetworkingSecurityTransitEncryption(
8144+
type=acns_transit_encryption,
8145+
)
81078146
mc.network_profile.advanced_networking = acns
8147+
elif acns_transit_encryption is not None:
8148+
if mc.network_profile.advanced_networking is None:
8149+
mc.network_profile.advanced_networking = self.models.AdvancedNetworking()
8150+
if mc.network_profile.advanced_networking.security is None:
8151+
mc.network_profile.advanced_networking.security = self.models.AdvancedNetworkingSecurity()
8152+
mc.network_profile.advanced_networking.security.transit_encryption = (
8153+
self.models.AdvancedNetworkingSecurityTransitEncryption(
8154+
type=acns_transit_encryption,
8155+
)
8156+
)
81088157
return mc
81098158

81108159
def update_http_proxy_config(self, mc: ManagedCluster) -> ManagedCluster:

0 commit comments

Comments
 (0)