Skip to content

Commit d427024

Browse files
authored
feat(acns): add transit encryption options for az create and update commands (#8784)
1 parent 2ab972b commit d427024

File tree

11 files changed

+3098
-2
lines changed

11 files changed

+3098
-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.0b12
16+
+++++++
17+
* Add option `--acns-transit-encryption-type <None|WireGuard>` to `az aks create/update`
18+
1519
18.0.0b11
1620
+++++++
1721
* Vendor new SDK and bump API version to 2025-04-02-preview.

src/aks-preview/azext_aks_preview/_consts.py

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

142+
# ACNS transit encryption type
143+
CONST_TRANSIT_ENCRYPTION_TYPE_NONE = "None"
144+
CONST_TRANSIT_ENCRYPTION_TYPE_WIREGUARD = "WireGuard"
145+
142146
# network pod ip allocation mode
143147
CONST_NETWORK_POD_IP_ALLOCATION_MODE_DYNAMIC_INDIVIDUAL = "DynamicIndividual"
144148
CONST_NETWORK_POD_IP_ALLOCATION_MODE_STATIC_BLOCK = "StaticBlock"

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@
145145
CONST_ADVANCED_NETWORKPOLICIES_NONE,
146146
CONST_ADVANCED_NETWORKPOLICIES_FQDN,
147147
CONST_ADVANCED_NETWORKPOLICIES_L7,
148+
CONST_TRANSIT_ENCRYPTION_TYPE_NONE,
149+
CONST_TRANSIT_ENCRYPTION_TYPE_WIREGUARD
148150
)
149151

150152
from azext_aks_preview._validators import (
@@ -320,6 +322,10 @@
320322
CONST_ADVANCED_NETWORKPOLICIES_FQDN,
321323
CONST_ADVANCED_NETWORKPOLICIES_L7,
322324
]
325+
transit_encryption_types = [
326+
CONST_TRANSIT_ENCRYPTION_TYPE_NONE,
327+
CONST_TRANSIT_ENCRYPTION_TYPE_WIREGUARD,
328+
]
323329
network_dataplanes = [CONST_NETWORK_DATAPLANE_AZURE, CONST_NETWORK_DATAPLANE_CILIUM]
324330
disk_driver_versions = [CONST_DISK_DRIVER_V1, CONST_DISK_DRIVER_V2]
325331
outbound_types = [
@@ -884,6 +890,12 @@ def load_arguments(self, _):
884890
is_preview=True,
885891
arg_type=get_enum_type(advanced_networkpolicies),
886892
)
893+
c.argument(
894+
"acns_transit_encryption_type",
895+
is_preview=True,
896+
arg_type=get_enum_type(transit_encryption_types),
897+
help="Specify the transit encryption type for ACNS. Available values are 'None' and 'WireGuard'.",
898+
)
887899
c.argument(
888900
"enable_retina_flow_logs",
889901
action="store_true",
@@ -1379,6 +1391,12 @@ def load_arguments(self, _):
13791391
is_preview=True,
13801392
arg_type=get_enum_type(advanced_networkpolicies),
13811393
)
1394+
c.argument(
1395+
"acns_transit_encryption_type",
1396+
is_preview=True,
1397+
arg_type=get_enum_type(transit_encryption_types),
1398+
help="Specify the transit encryption type for ACNS. Available values are 'None' and 'WireGuard'.",
1399+
)
13821400
c.argument(
13831401
"enable_retina_flow_logs",
13841402
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
@@ -678,6 +678,7 @@ def aks_create(
678678
disable_acns_observability=None,
679679
disable_acns_security=None,
680680
acns_advanced_networkpolicies=None,
681+
acns_transit_encryption_type=None,
681682
enable_retina_flow_logs=None,
682683
# nodepool
683684
crg_id=None,
@@ -911,6 +912,7 @@ def aks_update(
911912
disable_acns_observability=None,
912913
disable_acns_security=None,
913914
acns_advanced_networkpolicies=None,
915+
acns_transit_encryption_type=None,
914916
enable_retina_flow_logs=None,
915917
disable_retina_flow_logs=None,
916918
# metrics profile

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,21 @@ def get_acns_advanced_networkpolicies(self) -> Union[str, None]:
822822
)
823823
return self.raw_param.get("acns_advanced_networkpolicies")
824824

825+
def get_acns_transit_encryption_type(self) -> Union[str, None]:
826+
"""Get the value of acns_transit_encryption_type
827+
828+
:return: str or None
829+
"""
830+
disable_acns_security = self.raw_param.get("disable_acns_security")
831+
disable_acns = self.raw_param.get("disable_acns")
832+
acns_transit_encryption_type = self.raw_param.get("acns_transit_encryption_type")
833+
if acns_transit_encryption_type is not None:
834+
if disable_acns_security or disable_acns:
835+
raise MutuallyExclusiveArgumentError(
836+
"--disable-acns-security and --disable-acns cannot be used with --acns-transit-encryption-type."
837+
)
838+
return self.raw_param.get("acns_transit_encryption_type")
839+
825840
def get_retina_flow_logs(self, mc: ManagedCluster) -> Union[bool, None]:
826841
"""Get the enablement of retina flow logs
827842
@@ -2975,6 +2990,7 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
29752990
acns = None
29762991
(acns_enabled, acns_observability_enabled, acns_security_enabled) = self.context.get_acns_enablement()
29772992
acns_advanced_networkpolicies = self.context.get_acns_advanced_networkpolicies()
2993+
acns_transit_encryption_type = self.context.get_acns_transit_encryption_type()
29782994
if acns_enabled is not None:
29792995
acns = self.models.AdvancedNetworking(
29802996
enabled=acns_enabled,
@@ -2994,6 +3010,15 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
29943010
)
29953011
else:
29963012
acns.security.advanced_network_policies = acns_advanced_networkpolicies
3013+
if acns_transit_encryption_type is not None:
3014+
if acns.security is None:
3015+
acns.security = self.models.AdvancedNetworkingSecurity(
3016+
transit_encryption=self.models.AdvancedNetworkingSecurityTransitEncryption(
3017+
type=acns_transit_encryption_type
3018+
)
3019+
)
3020+
else:
3021+
acns.security.transit_encryption.type = acns_transit_encryption_type
29973022
network_profile.advanced_networking = acns
29983023
return mc
29993024

@@ -4064,6 +4089,7 @@ def update_acns_in_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
40644089
acns = None
40654090
(acns_enabled, acns_observability_enabled, acns_security_enabled) = self.context.get_acns_enablement()
40664091
acns_advanced_networkpolicies = self.context.get_acns_advanced_networkpolicies()
4092+
acns_transit_encryption_type = self.context.get_acns_transit_encryption_type()
40674093
if acns_enabled is not None:
40684094
acns = self.models.AdvancedNetworking(
40694095
enabled=acns_enabled,
@@ -4083,6 +4109,15 @@ def update_acns_in_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
40834109
)
40844110
else:
40854111
acns.security.advanced_network_policies = acns_advanced_networkpolicies
4112+
if acns_transit_encryption_type is not None:
4113+
if acns.security is None:
4114+
acns.security = self.models.AdvancedNetworkingSecurity(
4115+
transit_encryption=self.models.AdvancedNetworkingSecurityTransitEncryption(
4116+
type=acns_transit_encryption_type
4117+
)
4118+
)
4119+
else:
4120+
acns.security.transit_encryption.type = acns_transit_encryption_type
40864121
mc.network_profile.advanced_networking = acns
40874122
return mc
40884123

0 commit comments

Comments
 (0)