|
19 | 19 | CONST_AZURE_SERVICE_MESH_UPGRADE_COMMAND_ROLLBACK, |
20 | 20 | CONST_AZURE_SERVICE_MESH_UPGRADE_COMMAND_START, |
21 | 21 | CONST_AZURE_SERVICE_MESH_DEFAULT_EGRESS_NAMESPACE, |
| 22 | + CONST_AZURE_SERVICE_MESH_PROXY_REDIRECTION_CNI_CHAINING, |
| 23 | + CONST_AZURE_SERVICE_MESH_PROXY_REDIRECTION_INIT_CONTAINERS, |
22 | 24 | CONST_LOAD_BALANCER_SKU_BASIC, |
23 | 25 | CONST_MANAGED_CLUSTER_SKU_NAME_BASE, |
24 | 26 | CONST_MANAGED_CLUSTER_SKU_NAME_AUTOMATIC, |
@@ -3233,6 +3235,45 @@ def _handle_enable_disable_asm(self, new_profile: ServiceMeshProfile) -> Tuple[S |
3233 | 3235 |
|
3234 | 3236 | return new_profile, updated |
3235 | 3237 |
|
| 3238 | + def _handle_istio_cni_asm(self, new_profile: ServiceMeshProfile) -> Tuple[ServiceMeshProfile, bool]: |
| 3239 | + """Handle enable/disable Istio CNI proxy redirection mechanism.""" |
| 3240 | + updated = False |
| 3241 | + enable_istio_cni = self.raw_param.get("enable_istio_cni", False) |
| 3242 | + disable_istio_cni = self.raw_param.get("disable_istio_cni", False) |
| 3243 | + |
| 3244 | + if enable_istio_cni and disable_istio_cni: |
| 3245 | + raise MutuallyExclusiveArgumentError( |
| 3246 | + "Cannot specify --enable-istio-cni and " |
| 3247 | + "--disable-istio-cni at the same time." |
| 3248 | + ) |
| 3249 | + |
| 3250 | + # Check if service mesh is enabled before allowing CNI changes |
| 3251 | + if enable_istio_cni or disable_istio_cni: |
| 3252 | + if new_profile is None or new_profile.mode == CONST_AZURE_SERVICE_MESH_MODE_DISABLED: |
| 3253 | + raise ArgumentUsageError( |
| 3254 | + "Istio has not been enabled for this cluster, please refer to https://aka.ms/asm-aks-addon-docs " |
| 3255 | + "for more details on enabling Azure Service Mesh." |
| 3256 | + ) |
| 3257 | + |
| 3258 | + # Ensure istio profile exists |
| 3259 | + if new_profile.istio is None: |
| 3260 | + new_profile.istio = self.models.IstioServiceMesh() # pylint: disable=no-member |
| 3261 | + |
| 3262 | + # Ensure components exist |
| 3263 | + if new_profile.istio.components is None: |
| 3264 | + new_profile.istio.components = self.models.IstioComponents() # pylint: disable=no-member |
| 3265 | + |
| 3266 | + if enable_istio_cni: |
| 3267 | + new_profile.istio.components.proxy_redirection_mechanism = \ |
| 3268 | + CONST_AZURE_SERVICE_MESH_PROXY_REDIRECTION_CNI_CHAINING |
| 3269 | + updated = True |
| 3270 | + elif disable_istio_cni: |
| 3271 | + new_profile.istio.components.proxy_redirection_mechanism = \ |
| 3272 | + CONST_AZURE_SERVICE_MESH_PROXY_REDIRECTION_INIT_CONTAINERS |
| 3273 | + updated = True |
| 3274 | + |
| 3275 | + return new_profile, updated |
| 3276 | + |
3236 | 3277 | # pylint: disable=too-many-branches,too-many-locals,too-many-statements |
3237 | 3278 | def update_azure_service_mesh_profile(self) -> ServiceMeshProfile: |
3238 | 3279 | """ Update azure service mesh profile. |
@@ -3267,6 +3308,9 @@ def update_azure_service_mesh_profile(self) -> ServiceMeshProfile: |
3267 | 3308 | new_profile, updated_upgrade_asm = self._handle_upgrade_asm(new_profile) |
3268 | 3309 | updated |= updated_upgrade_asm |
3269 | 3310 |
|
| 3311 | + new_profile, updated_istio_cni = self._handle_istio_cni_asm(new_profile) |
| 3312 | + updated |= updated_istio_cni |
| 3313 | + |
3270 | 3314 | if updated: |
3271 | 3315 | return new_profile |
3272 | 3316 | return self.mc.service_mesh_profile |
|
0 commit comments