Skip to content

Commit aae778c

Browse files
committed
{AKS} Add mTLS as transit encryption type for ACNS
Add support for mTLS as a new ACNS transit encryption type in the aks-preview extension, including CLI enum exposure and validation that prevents incompatible combinations with L7 advanced network policies and Istio service mesh during both create and update flows. - Add mTLS to --acns-transit-encryption-type allowed values and help text for az aks create and az aks update. - Add validation blocking mTLS when L7 advanced network policies are requested or already enabled, and when Azure Service Mesh (Istio) is enabled or already present. - Improve error messages to reference exact CLI flags and clarify when conflicts come from existing cluster state. - Guard aks wait calls with is_live check to prevent VCR cassette mismatch in playback mode. - Add/extend unit tests, scenario tests, and recordings for the new mTLS option. Signed-off-by: Quang Nguyen <nguyenquang@microsoft.com>
1 parent 1089267 commit aae778c

File tree

9 files changed

+2827
-5
lines changed

9 files changed

+2827
-5
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+
19.0.0b25
16+
+++++++
17+
* Add 'mTLS' as a transit encryption type option for `--acns-transit-encryption-type` in `az aks create/update`
18+
1519
19.0.0b24
1620
+++++++
1721
* Vendor new SDK and bump API version to 2026-01-02-preview.

src/aks-preview/azext_aks_preview/_consts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
# ACNS transit encryption type
155155
CONST_TRANSIT_ENCRYPTION_TYPE_NONE = "None"
156156
CONST_TRANSIT_ENCRYPTION_TYPE_WIREGUARD = "WireGuard"
157+
CONST_TRANSIT_ENCRYPTION_TYPE_MTLS = "mTLS"
157158

158159
# ACNS performance acceleration mode
159160
CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE = "None"

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
CONST_ADVANCED_NETWORKPOLICIES_L7,
159159
CONST_TRANSIT_ENCRYPTION_TYPE_NONE,
160160
CONST_TRANSIT_ENCRYPTION_TYPE_WIREGUARD,
161+
CONST_TRANSIT_ENCRYPTION_TYPE_MTLS,
161162
CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH,
162163
CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE,
163164
CONST_UPGRADE_STRATEGY_ROLLING,
@@ -360,6 +361,7 @@
360361
transit_encryption_types = [
361362
CONST_TRANSIT_ENCRYPTION_TYPE_NONE,
362363
CONST_TRANSIT_ENCRYPTION_TYPE_WIREGUARD,
364+
CONST_TRANSIT_ENCRYPTION_TYPE_MTLS,
363365
]
364366
acns_datapath_acceleration_modes = [
365367
CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE,
@@ -970,7 +972,7 @@ def load_arguments(self, _):
970972
"acns_transit_encryption_type",
971973
is_preview=True,
972974
arg_type=get_enum_type(transit_encryption_types),
973-
help="Specify the transit encryption type for ACNS. Available values are 'None' and 'WireGuard'.",
975+
help="Specify the transit encryption type for ACNS. Available values are 'None', 'WireGuard', and 'mTLS'.",
974976
)
975977
c.argument(
976978
"enable_retina_flow_logs",
@@ -1635,7 +1637,7 @@ def load_arguments(self, _):
16351637
"acns_transit_encryption_type",
16361638
is_preview=True,
16371639
arg_type=get_enum_type(transit_encryption_types),
1638-
help="Specify the transit encryption type for ACNS. Available values are 'None' and 'WireGuard'.",
1640+
help="Specify the transit encryption type for ACNS. Available values are 'None', 'WireGuard', and 'mTLS'.",
16391641
)
16401642
c.argument(
16411643
"enable_retina_flow_logs",

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
CONST_MANAGED_GATEWAY_INSTALLATION_STANDARD,
5050
CONST_MANAGED_GATEWAY_INSTALLATION_DISABLED,
5151
CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH,
52-
CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE
52+
CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE,
53+
CONST_TRANSIT_ENCRYPTION_TYPE_MTLS,
54+
CONST_ADVANCED_NETWORKPOLICIES_L7,
5355
)
5456
from azext_aks_preview.azurecontainerstorage._consts import (
5557
CONST_ACSTOR_EXT_INSTALLATION_NAME,
@@ -917,6 +919,49 @@ def get_acns_transit_encryption_type(self) -> Union[str, None]:
917919
raise MutuallyExclusiveArgumentError(
918920
"--disable-acns-security and --disable-acns cannot be used with --acns-transit-encryption-type."
919921
)
922+
if acns_transit_encryption_type == CONST_TRANSIT_ENCRYPTION_TYPE_MTLS:
923+
# Check CLI args for L7
924+
acns_advanced_networkpolicies = self.raw_param.get("acns_advanced_networkpolicies")
925+
if acns_advanced_networkpolicies == CONST_ADVANCED_NETWORKPOLICIES_L7:
926+
raise MutuallyExclusiveArgumentError(
927+
"'--acns-transit-encryption-type mTLS' cannot be used with "
928+
"'--acns-advanced-networkpolicies L7'. "
929+
"Please choose either '--acns-advanced-networkpolicies L7' or "
930+
"'--acns-transit-encryption-type mTLS', but not both."
931+
)
932+
# Check CLI args for Istio
933+
enable_asm = self.raw_param.get("enable_azure_service_mesh", False)
934+
if enable_asm:
935+
raise MutuallyExclusiveArgumentError(
936+
"'--acns-transit-encryption-type mTLS' cannot be used with "
937+
"'--enable-azure-service-mesh'. "
938+
"Please remove '--enable-azure-service-mesh' or choose a different "
939+
"transit encryption type."
940+
)
941+
# On update, check existing cluster state
942+
if self.decorator_mode == DecoratorMode.UPDATE and self.mc:
943+
# Check if existing cluster has L7 enabled and user is not changing it
944+
if (acns_advanced_networkpolicies is None and
945+
self.mc.network_profile and
946+
self.mc.network_profile.advanced_networking and
947+
self.mc.network_profile.advanced_networking.security and
948+
self.mc.network_profile.advanced_networking.security.advanced_network_policies ==
949+
CONST_ADVANCED_NETWORKPOLICIES_L7):
950+
raise MutuallyExclusiveArgumentError(
951+
"'--acns-transit-encryption-type mTLS' cannot be used with L7 advanced network policies. "
952+
"The existing cluster already has L7 enabled. Please disable L7 by passing "
953+
"'--acns-advanced-networkpolicies None' or choose a different transit encryption type."
954+
)
955+
# Check if existing cluster has Istio enabled and user is not disabling it
956+
disable_asm = self.raw_param.get("disable_azure_service_mesh", False)
957+
if (not disable_asm and
958+
self.mc.service_mesh_profile and
959+
self.mc.service_mesh_profile.mode == CONST_AZURE_SERVICE_MESH_MODE_ISTIO):
960+
raise MutuallyExclusiveArgumentError(
961+
"'--acns-transit-encryption-type mTLS' cannot be used with Istio service mesh. "
962+
"The existing cluster already has Istio enabled. Please disable Istio by passing "
963+
"'--disable-azure-service-mesh' or choose a different transit encryption type."
964+
)
920965
return self.raw_param.get("acns_transit_encryption_type")
921966

922967
# Container network logs is the new name for retina flow logs.

0 commit comments

Comments
 (0)