Skip to content

Commit b6d3ba7

Browse files
committed
feat(acns): add transit encryption options for az create and update commands
Signed-off-by: Quang Nguyen <nguyenquang@microsoft.com>
1 parent 67d6cc8 commit b6d3ba7

File tree

11 files changed

+2693
-2
lines changed

11 files changed

+2693
-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.0b11
16+
+++++++
17+
* Add option `--acns-transit-encryption-type <None|WireGuard>` to `az aks create/update`
18+
1519
18.0.0b10
1620
+++++++
1721
* Wrap the ARG call in the managed namespace list command

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",
@@ -1368,6 +1380,12 @@ def load_arguments(self, _):
13681380
is_preview=True,
13691381
arg_type=get_enum_type(advanced_networkpolicies),
13701382
)
1383+
c.argument(
1384+
"acns_transit_encryption_type",
1385+
is_preview=True,
1386+
arg_type=get_enum_type(transit_encryption_types),
1387+
help="Specify the transit encryption type for ACNS. Available values are 'None' and 'WireGuard'.",
1388+
)
13711389
c.argument(
13721390
"enable_retina_flow_logs",
13731391
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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,21 @@ def get_acns_advanced_networkpolicies(self) -> Union[str, None]:
823823
)
824824
return self.raw_param.get("acns_advanced_networkpolicies")
825825

826+
def get_acns_transit_encryption_type(self) -> Union[str, None]:
827+
"""Get the value of acns_transit_encryption_type
828+
829+
:return: str or None
830+
"""
831+
disable_acns_security = self.raw_param.get("disable_acns_security")
832+
disable_acns = self.raw_param.get("disable_acns")
833+
acns_transit_encryption_type = self.raw_param.get("acns_transit_encryption_type")
834+
if acns_transit_encryption_type is not None:
835+
if disable_acns_security or disable_acns:
836+
raise MutuallyExclusiveArgumentError(
837+
"--disable-acns-security and --disable-acns cannot be used with acns_transit_encryption_type."
838+
)
839+
return self.raw_param.get("acns_transit_encryption_type")
840+
826841
def get_retina_flow_logs(self, mc: ManagedCluster) -> Union[bool, None]:
827842
"""Get the enablement of retina flow logs
828843
@@ -2976,6 +2991,7 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
29762991
acns = None
29772992
(acns_enabled, acns_observability_enabled, acns_security_enabled) = self.context.get_acns_enablement()
29782993
acns_advanced_networkpolicies = self.context.get_acns_advanced_networkpolicies()
2994+
acns_transit_encryption_type = self.context.get_acns_transit_encryption_type()
29792995
if acns_enabled is not None:
29802996
acns = self.models.AdvancedNetworking(
29812997
enabled=acns_enabled,
@@ -2995,6 +3011,13 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
29953011
)
29963012
else:
29973013
acns.security.advanced_network_policies = acns_advanced_networkpolicies
3014+
if acns_transit_encryption_type is not None:
3015+
if acns.security is None:
3016+
acns.security = self.models.AdvancedNetworkingSecurity(
3017+
type=acns_transit_encryption_type
3018+
)
3019+
else:
3020+
acns.security.type = acns_transit_encryption_type
29983021
network_profile.advanced_networking = acns
29993022
return mc
30003023

@@ -4075,6 +4098,7 @@ def update_acns_in_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
40754098
acns = None
40764099
(acns_enabled, acns_observability_enabled, acns_security_enabled) = self.context.get_acns_enablement()
40774100
acns_advanced_networkpolicies = self.context.get_acns_advanced_networkpolicies()
4101+
acns_transit_encryption_type = self.context.get_acns_transit_encryption_type()
40784102
if acns_enabled is not None:
40794103
acns = self.models.AdvancedNetworking(
40804104
enabled=acns_enabled,
@@ -4094,6 +4118,13 @@ def update_acns_in_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
40944118
)
40954119
else:
40964120
acns.security.advanced_network_policies = acns_advanced_networkpolicies
4121+
if acns_transit_encryption_type is not None:
4122+
if acns.security is None:
4123+
acns.security = self.models.AdvancedNetworkingSecurity(
4124+
type=acns_transit_encryption_type
4125+
)
4126+
else:
4127+
acns.security.type = acns_transit_encryption_type
40974128
mc.network_profile.advanced_networking = acns
40984129
return mc
40994130

0 commit comments

Comments
 (0)