Skip to content

Commit 7ce1ea6

Browse files
authored
feat(acns): Add mTLS as transit encryption type for ACNS (#9668)
1 parent e40aaa7 commit 7ce1ea6

File tree

9 files changed

+2799
-5
lines changed

9 files changed

+2799
-5
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ To release a new version, please select a new version number (usually plus 1 to
1111

1212
Pending
1313
+++++++
14+
19.0.0b26
15+
+++++++
1416
* `az aks create/update`: Add `--enable-app-routing-istio` / `--disable-app-routing-istio` (short: `--enable-ari` / `--disable-ari`) flags to enable or disable Istio as a Gateway API implementation for App Routing.
1517
* `az aks approuting gateway istio enable/disable`: Add new subcommands to enable or disable the Istio Gateway API implementation for App Routing on an existing cluster.
18+
* Add 'mTLS' as a transit encryption type option for `--acns-transit-encryption-type` in `az aks create/update`
1619

1720
19.0.0b25
1821
+++++++

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",
@@ -1648,7 +1650,7 @@ def load_arguments(self, _):
16481650
"acns_transit_encryption_type",
16491651
is_preview=True,
16501652
arg_type=get_enum_type(transit_encryption_types),
1651-
help="Specify the transit encryption type for ACNS. Available values are 'None' and 'WireGuard'.",
1653+
help="Specify the transit encryption type for ACNS. Available values are 'None', 'WireGuard', and 'mTLS'.",
16521654
)
16531655
c.argument(
16541656
"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
@@ -51,7 +51,9 @@
5151
CONST_APP_ROUTING_ISTIO_MODE_ENABLED,
5252
CONST_APP_ROUTING_ISTIO_MODE_DISABLED,
5353
CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH,
54-
CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE
54+
CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE,
55+
CONST_TRANSIT_ENCRYPTION_TYPE_MTLS,
56+
CONST_ADVANCED_NETWORKPOLICIES_L7,
5557
)
5658
from azext_aks_preview.azurecontainerstorage._consts import (
5759
CONST_ACSTOR_EXT_INSTALLATION_NAME,
@@ -919,6 +921,49 @@ def get_acns_transit_encryption_type(self) -> Union[str, None]:
919921
raise MutuallyExclusiveArgumentError(
920922
"--disable-acns-security and --disable-acns cannot be used with --acns-transit-encryption-type."
921923
)
924+
if acns_transit_encryption_type == CONST_TRANSIT_ENCRYPTION_TYPE_MTLS:
925+
# Check CLI args for L7
926+
acns_advanced_networkpolicies = self.raw_param.get("acns_advanced_networkpolicies")
927+
if acns_advanced_networkpolicies == CONST_ADVANCED_NETWORKPOLICIES_L7:
928+
raise MutuallyExclusiveArgumentError(
929+
"'--acns-transit-encryption-type mTLS' cannot be used with "
930+
"'--acns-advanced-networkpolicies L7'. "
931+
"Please choose either '--acns-advanced-networkpolicies L7' or "
932+
"'--acns-transit-encryption-type mTLS', but not both."
933+
)
934+
# Check CLI args for Istio
935+
enable_asm = self.raw_param.get("enable_azure_service_mesh", False)
936+
if enable_asm:
937+
raise MutuallyExclusiveArgumentError(
938+
"'--acns-transit-encryption-type mTLS' cannot be used with "
939+
"'--enable-azure-service-mesh'. "
940+
"Please remove '--enable-azure-service-mesh' or choose a different "
941+
"transit encryption type."
942+
)
943+
# On update, check existing cluster state
944+
if self.decorator_mode == DecoratorMode.UPDATE and self.mc:
945+
# Check if existing cluster has L7 enabled and user is not changing it
946+
if (acns_advanced_networkpolicies is None and
947+
self.mc.network_profile and
948+
self.mc.network_profile.advanced_networking and
949+
self.mc.network_profile.advanced_networking.security and
950+
self.mc.network_profile.advanced_networking.security.advanced_network_policies ==
951+
CONST_ADVANCED_NETWORKPOLICIES_L7):
952+
raise MutuallyExclusiveArgumentError(
953+
"'--acns-transit-encryption-type mTLS' cannot be used with L7 advanced network policies. "
954+
"The existing cluster already has L7 enabled. Please disable L7 by passing "
955+
"'--acns-advanced-networkpolicies None' or choose a different transit encryption type."
956+
)
957+
# Check if existing cluster has Istio enabled and user is not disabling it
958+
disable_asm = self.raw_param.get("disable_azure_service_mesh", False)
959+
if (not disable_asm and
960+
self.mc.service_mesh_profile and
961+
self.mc.service_mesh_profile.mode == CONST_AZURE_SERVICE_MESH_MODE_ISTIO):
962+
raise MutuallyExclusiveArgumentError(
963+
"'--acns-transit-encryption-type mTLS' cannot be used with Istio service mesh. "
964+
"The existing cluster already has Istio enabled. Please disable Istio by passing "
965+
"'--disable-azure-service-mesh' or choose a different transit encryption type."
966+
)
922967
return self.raw_param.get("acns_transit_encryption_type")
923968

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

0 commit comments

Comments
 (0)