Skip to content

Commit d9099af

Browse files
committed
feat(acns): add transit encryption options for az create and update commands
Signed-off-by: Quang Nguyen <[email protected]>
1 parent 9a05db7 commit d9099af

File tree

11 files changed

+2691
-2
lines changed

11 files changed

+2691
-2
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ To release a new version, please select a new version number (usually plus 1 to
1212
Pending
1313
+++++++
1414

15+
18.0.0b3
16+
+++++++
17+
* Add option `--acns-transit-encryption-type <None|WireGuard>` to `az aks create/update`
18+
1519
18.0.0b2
1620
+++++++
1721
* Vendor new SDK and bump API version to 2025-03-02-preview.

src/aks-preview/azext_aks_preview/_consts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@
137137
CONST_ADVANCED_NETWORKPOLICIES_FQDN = "FQDN"
138138
CONST_ADVANCED_NETWORKPOLICIES_L7 = "L7"
139139

140+
# ACNS transit encryption type
141+
CONST_TRANSIT_ENCRYPTION_TYPE_NONE = "None"
142+
CONST_TRANSIT_ENCRYPTION_TYPE_WIREGUARD = "WireGuard"
143+
140144
# network pod ip allocation mode
141145
CONST_NETWORK_POD_IP_ALLOCATION_MODE_DYNAMIC_INDIVIDUAL = "DynamicIndividual"
142146
CONST_NETWORK_POD_IP_ALLOCATION_MODE_STATIC_BLOCK = "StaticBlock"

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@
135135
CONST_ADVANCED_NETWORKPOLICIES_NONE,
136136
CONST_ADVANCED_NETWORKPOLICIES_FQDN,
137137
CONST_ADVANCED_NETWORKPOLICIES_L7,
138+
CONST_TRANSIT_ENCRYPTION_TYPE_NONE,
139+
CONST_TRANSIT_ENCRYPTION_TYPE_WIREGUARD
138140
)
139141

140142
from azext_aks_preview._validators import (
@@ -300,6 +302,10 @@
300302
CONST_ADVANCED_NETWORKPOLICIES_FQDN,
301303
CONST_ADVANCED_NETWORKPOLICIES_L7,
302304
]
305+
transit_encryption_types = [
306+
CONST_TRANSIT_ENCRYPTION_TYPE_NONE,
307+
CONST_TRANSIT_ENCRYPTION_TYPE_WIREGUARD,
308+
]
303309
network_dataplanes = [CONST_NETWORK_DATAPLANE_AZURE, CONST_NETWORK_DATAPLANE_CILIUM]
304310
disk_driver_versions = [CONST_DISK_DRIVER_V1, CONST_DISK_DRIVER_V2]
305311
outbound_types = [
@@ -846,6 +852,11 @@ def load_arguments(self, _):
846852
is_preview=True,
847853
arg_type=get_enum_type(advanced_networkpolicies),
848854
)
855+
c.argument(
856+
"acns_transit_encryption_type",
857+
is_preview=True,
858+
arg_type=get_enum_type(transit_encryption_types),
859+
)
849860
c.argument(
850861
"enable_retina_flow_logs",
851862
action="store_true",
@@ -1325,6 +1336,11 @@ def load_arguments(self, _):
13251336
is_preview=True,
13261337
arg_type=get_enum_type(advanced_networkpolicies),
13271338
)
1339+
c.argument(
1340+
"acns_transit_encryption_type",
1341+
is_preview=True,
1342+
arg_type=get_enum_type(transit_encryption_types),
1343+
)
13281344
c.argument(
13291345
"enable_retina_flow_logs",
13301346
action="store_true",

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ def aks_create(
499499
disable_acns_observability=None,
500500
disable_acns_security=None,
501501
acns_advanced_networkpolicies=None,
502+
acns_transit_encryption_type=None,
502503
enable_retina_flow_logs=None,
503504
# nodepool
504505
crg_id=None,
@@ -730,6 +731,7 @@ def aks_update(
730731
disable_acns_observability=None,
731732
disable_acns_security=None,
732733
acns_advanced_networkpolicies=None,
734+
acns_transit_encryption_type=None,
733735
enable_retina_flow_logs=None,
734736
disable_retina_flow_logs=None,
735737
# metrics profile

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,21 @@ def get_acns_advanced_networkpolicies(self) -> Union[str, None]:
781781
)
782782
return self.raw_param.get("acns_advanced_networkpolicies")
783783

784+
def get_acns_transit_encryption_type(self) -> Union[str, None]:
785+
"""Get the value of acns_transit_encryption_type
786+
787+
:return: str or None
788+
"""
789+
disable_acns_security = self.raw_param.get("disable_acns_security")
790+
disable_acns = self.raw_param.get("disable_acns")
791+
acns_transit_encryption_type = self.raw_param.get("acns_transit_encryption_type")
792+
if acns_transit_encryption_type is not None:
793+
if disable_acns_security or disable_acns:
794+
raise MutuallyExclusiveArgumentError(
795+
"--disable-acns-security and --disable-acns cannot be used with acns_transit_encryption_type."
796+
)
797+
return self.raw_param.get("acns_transit_encryption_type")
798+
784799
def get_retina_flow_logs(self, mc: ManagedCluster) -> Union[bool, None]:
785800
"""Get the enablement of retina flow logs
786801
@@ -2924,6 +2939,7 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
29242939
acns = None
29252940
(acns_enabled, acns_observability_enabled, acns_security_enabled) = self.context.get_acns_enablement()
29262941
acns_advanced_networkpolicies = self.context.get_acns_advanced_networkpolicies()
2942+
acns_transit_encryption_type = self.context.get_acns_transit_encryption_type()
29272943
if acns_enabled is not None:
29282944
acns = self.models.AdvancedNetworking(
29292945
enabled=acns_enabled,
@@ -2943,6 +2959,13 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
29432959
)
29442960
else:
29452961
acns.security.advanced_network_policies = acns_advanced_networkpolicies
2962+
if acns_transit_encryption_type is not None:
2963+
if acns.security is None:
2964+
acns.security = self.models.AdvancedNetworkingSecurity(
2965+
type=acns_transit_encryption_type
2966+
)
2967+
else:
2968+
acns.security.type = acns_transit_encryption_type
29462969
network_profile.advanced_networking = acns
29472970
return mc
29482971

@@ -4020,6 +4043,7 @@ def update_acns_in_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
40204043
acns = None
40214044
(acns_enabled, acns_observability_enabled, acns_security_enabled) = self.context.get_acns_enablement()
40224045
acns_advanced_networkpolicies = self.context.get_acns_advanced_networkpolicies()
4046+
acns_transit_encryption_type = self.context.get_acns_transit_encryption_type()
40234047
if acns_enabled is not None:
40244048
acns = self.models.AdvancedNetworking(
40254049
enabled=acns_enabled,
@@ -4039,6 +4063,13 @@ def update_acns_in_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
40394063
)
40404064
else:
40414065
acns.security.advanced_network_policies = acns_advanced_networkpolicies
4066+
if acns_transit_encryption_type is not None:
4067+
if acns.security is None:
4068+
acns.security = self.models.AdvancedNetworkingSecurity(
4069+
type=acns_transit_encryption_type
4070+
)
4071+
else:
4072+
acns.security.type = acns_transit_encryption_type
40424073
mc.network_profile.advanced_networking = acns
40434074
return mc
40444075

0 commit comments

Comments
 (0)