-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[AKS] Add mesh Istio CNI commands for az aks mesh #9286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
efacebb
ea12094
b31e731
2b67d0f
988bb4b
728d64a
62fec0a
748b73f
fcdd8ae
92e6e4b
c1f93f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ | |
| CONST_AZURE_SERVICE_MESH_UPGRADE_COMMAND_ROLLBACK, | ||
| CONST_AZURE_SERVICE_MESH_UPGRADE_COMMAND_START, | ||
| CONST_AZURE_SERVICE_MESH_DEFAULT_EGRESS_NAMESPACE, | ||
| CONST_AZURE_SERVICE_MESH_PROXY_REDIRECTION_CNI_CHAINING, | ||
| CONST_AZURE_SERVICE_MESH_PROXY_REDIRECTION_INIT_CONTAINERS, | ||
| CONST_LOAD_BALANCER_SKU_BASIC, | ||
| CONST_MANAGED_CLUSTER_SKU_NAME_BASE, | ||
| CONST_MANAGED_CLUSTER_SKU_NAME_AUTOMATIC, | ||
|
|
@@ -3233,6 +3235,45 @@ def _handle_enable_disable_asm(self, new_profile: ServiceMeshProfile) -> Tuple[S | |
|
|
||
| return new_profile, updated | ||
|
|
||
| def _handle_istio_cni_asm(self, new_profile: ServiceMeshProfile) -> Tuple[ServiceMeshProfile, bool]: | ||
| """Handle enable/disable Istio CNI proxy redirection mechanism.""" | ||
| updated = False | ||
| enable_istio_cni = self.raw_param.get("enable_istio_cni", False) | ||
| disable_istio_cni = self.raw_param.get("disable_istio_cni", False) | ||
|
|
||
| if enable_istio_cni and disable_istio_cni: | ||
| raise MutuallyExclusiveArgumentError( | ||
| "Cannot specify --enable-istio-cni and " | ||
| "--disable-istio-cni at the same time." | ||
| ) | ||
|
|
||
| # Check if service mesh is enabled before allowing CNI changes | ||
| if enable_istio_cni or disable_istio_cni: | ||
| if new_profile is None or new_profile.mode == CONST_AZURE_SERVICE_MESH_MODE_DISABLED: | ||
| raise ArgumentUsageError( | ||
| "Istio has not been enabled for this cluster, please refer to https://aka.ms/asm-aks-addon-docs " | ||
| "for more details on enabling Azure Service Mesh." | ||
| ) | ||
|
|
||
| # Ensure istio profile exists | ||
| if new_profile.istio is None: | ||
german1608 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| new_profile.istio = self.models.IstioServiceMesh() # pylint: disable=no-member | ||
|
|
||
| # Ensure components exist | ||
| if new_profile.istio.components is None: | ||
| new_profile.istio.components = self.models.IstioComponents() # pylint: disable=no-member | ||
|
|
||
| if enable_istio_cni: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like enable = cni, disable = init containers. Makes me wonder: could there be more modes? Do we want
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't foresee more modes for proxy redirection mechanism. If we go down the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reason I say feels weird UX is because user can opt-out/opt-in arbitrarily, and re-using az aks mesh for that seems awkwards.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, fair enough. |
||
| new_profile.istio.components.proxy_redirection_mechanism = \ | ||
| CONST_AZURE_SERVICE_MESH_PROXY_REDIRECTION_CNI_CHAINING | ||
| updated = True | ||
| elif disable_istio_cni: | ||
| new_profile.istio.components.proxy_redirection_mechanism = \ | ||
| CONST_AZURE_SERVICE_MESH_PROXY_REDIRECTION_INIT_CONTAINERS | ||
| updated = True | ||
|
|
||
| return new_profile, updated | ||
|
|
||
| # pylint: disable=too-many-branches,too-many-locals,too-many-statements | ||
| def update_azure_service_mesh_profile(self) -> ServiceMeshProfile: | ||
| """ Update azure service mesh profile. | ||
|
|
@@ -3267,6 +3308,9 @@ def update_azure_service_mesh_profile(self) -> ServiceMeshProfile: | |
| new_profile, updated_upgrade_asm = self._handle_upgrade_asm(new_profile) | ||
| updated |= updated_upgrade_asm | ||
|
|
||
| new_profile, updated_istio_cni = self._handle_istio_cni_asm(new_profile) | ||
| updated |= updated_istio_cni | ||
|
|
||
| if updated: | ||
| return new_profile | ||
| return self.mc.service_mesh_profile | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs no_wait parameter
command declares supports_no_wait=True but functions don't accept the parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the others aks mesh commands uses supports_no_wait
azure-cli-extensions/src/aks-preview/azext_aks_preview/custom.py
Lines 3753 to 3764 in efacebb
All the other commands declare supports_no_wait
azure-cli-extensions/src/aks-preview/azext_aks_preview/commands.py
Line 404 in efacebb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is surprising. even though command declares
supports_no_waitbut the func is called without the param, its being defaulted to false. maybe that's the default behavior.@FumingZhang might know better here but I am okay with the change as long as its consistent with other
az aks meshcommands.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems there is a gap between the declaration and implementation. It's fine to leave it as is for this PR, but it would be better to address the issue in a future PR. Supporting the --no-wait option is straightforward; you just need to wrap the SDK call using the
sdk_no_wait(no_wait, <sdk-call>, <params>)function provided by azure-cli.