|
51 | 51 | CONST_APP_ROUTING_ISTIO_MODE_ENABLED, |
52 | 52 | CONST_APP_ROUTING_ISTIO_MODE_DISABLED, |
53 | 53 | 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, |
55 | 57 | ) |
56 | 58 | from azext_aks_preview.azurecontainerstorage._consts import ( |
57 | 59 | CONST_ACSTOR_EXT_INSTALLATION_NAME, |
@@ -919,6 +921,49 @@ def get_acns_transit_encryption_type(self) -> Union[str, None]: |
919 | 921 | raise MutuallyExclusiveArgumentError( |
920 | 922 | "--disable-acns-security and --disable-acns cannot be used with --acns-transit-encryption-type." |
921 | 923 | ) |
| 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 | + ) |
922 | 967 | return self.raw_param.get("acns_transit_encryption_type") |
923 | 968 |
|
924 | 969 | # Container network logs is the new name for retina flow logs. |
|
0 commit comments