Skip to content

Commit 1ab7818

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 21e9783 commit 1ab7818

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.0b4
16+
+++++++
17+
* Add option `--acns-transit-encryption-type <None|WireGuard>` to `az aks create/update`
18+
1519
18.0.0b3
1620
+++++++
1721
* Add basic lb sku migration support `az aks update --load-balancer-sku standard`

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: 18 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,12 @@ 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+
help="Specify the transit encryption type for ACNS. Available values are 'None' and 'WireGuard'.",
860+
)
849861
c.argument(
850862
"enable_retina_flow_logs",
851863
action="store_true",
@@ -1330,6 +1342,12 @@ def load_arguments(self, _):
13301342
is_preview=True,
13311343
arg_type=get_enum_type(advanced_networkpolicies),
13321344
)
1345+
c.argument(
1346+
"acns_transit_encryption_type",
1347+
is_preview=True,
1348+
arg_type=get_enum_type(transit_encryption_types),
1349+
help="Specify the transit encryption type for ACNS. Available values are 'None' and 'WireGuard'.",
1350+
)
13331351
c.argument(
13341352
"enable_retina_flow_logs",
13351353
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,
@@ -731,6 +732,7 @@ def aks_update(
731732
disable_acns_observability=None,
732733
disable_acns_security=None,
733734
acns_advanced_networkpolicies=None,
735+
acns_transit_encryption_type=None,
734736
enable_retina_flow_logs=None,
735737
disable_retina_flow_logs=None,
736738
# 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
@@ -2966,6 +2981,7 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
29662981
acns = None
29672982
(acns_enabled, acns_observability_enabled, acns_security_enabled) = self.context.get_acns_enablement()
29682983
acns_advanced_networkpolicies = self.context.get_acns_advanced_networkpolicies()
2984+
acns_transit_encryption_type = self.context.get_acns_transit_encryption_type()
29692985
if acns_enabled is not None:
29702986
acns = self.models.AdvancedNetworking(
29712987
enabled=acns_enabled,
@@ -2985,6 +3001,13 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
29853001
)
29863002
else:
29873003
acns.security.advanced_network_policies = acns_advanced_networkpolicies
3004+
if acns_transit_encryption_type is not None:
3005+
if acns.security is None:
3006+
acns.security = self.models.AdvancedNetworkingSecurity(
3007+
type=acns_transit_encryption_type
3008+
)
3009+
else:
3010+
acns.security.type = acns_transit_encryption_type
29883011
network_profile.advanced_networking = acns
29893012
return mc
29903013

@@ -4065,6 +4088,7 @@ def update_acns_in_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
40654088
acns = None
40664089
(acns_enabled, acns_observability_enabled, acns_security_enabled) = self.context.get_acns_enablement()
40674090
acns_advanced_networkpolicies = self.context.get_acns_advanced_networkpolicies()
4091+
acns_transit_encryption_type = self.context.get_acns_transit_encryption_type()
40684092
if acns_enabled is not None:
40694093
acns = self.models.AdvancedNetworking(
40704094
enabled=acns_enabled,
@@ -4084,6 +4108,13 @@ def update_acns_in_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
40844108
)
40854109
else:
40864110
acns.security.advanced_network_policies = acns_advanced_networkpolicies
4111+
if acns_transit_encryption_type is not None:
4112+
if acns.security is None:
4113+
acns.security = self.models.AdvancedNetworkingSecurity(
4114+
type=acns_transit_encryption_type
4115+
)
4116+
else:
4117+
acns.security.type = acns_transit_encryption_type
40874118
mc.network_profile.advanced_networking = acns
40884119
return mc
40894120

0 commit comments

Comments
 (0)