diff --git a/src/aks-preview/azext_aks_preview/_help.py b/src/aks-preview/azext_aks_preview/_help.py index cc7cce3865f..17581041e38 100644 --- a/src/aks-preview/azext_aks_preview/_help.py +++ b/src/aks-preview/azext_aks_preview/_help.py @@ -805,6 +805,25 @@ """ +helps['aks delete'] = """ + type: command + short-summary: Delete a managed Kubernetes cluster. + parameters: + - name: --if-match + type: string + short-summary: The value provided will be compared to the ETag of the managed cluster, if it matches the operation will proceed. If it does not match, the request will be rejected to prevent accidental overwrites. + - name: --if-none-match + type: string + short-summary: Not applicable for delete operations. This option will be ignored if provided. + - name: --ignore-pod-disruption-budget + type: bool + short-summary: Delete those pods on a node without considering Pod Disruption Budget. + examples: + - name: Delete a managed Kubernetes cluster. + text: az aks delete --name MyManagedCluster --resource-group MyResourceGroup + crafted: true +""" + helps['aks scale'] = """ type: command short-summary: Scale the node pool in a managed Kubernetes cluster. diff --git a/src/aks-preview/azext_aks_preview/_params.py b/src/aks-preview/azext_aks_preview/_params.py index 9e5d78cde69..5dd30c6a41d 100644 --- a/src/aks-preview/azext_aks_preview/_params.py +++ b/src/aks-preview/azext_aks_preview/_params.py @@ -1821,6 +1821,11 @@ def load_arguments(self, _): help="Disable continuous control plane and addon monitor for the cluster.", ) + with self.argument_context("aks delete") as c: + c.argument("if_match") + c.argument("if_none_match") + c.argument("ignore_pod_disruption_budget", action="store_true") + with self.argument_context("aks upgrade") as c: c.argument("kubernetes_version", completer=get_k8s_upgrades_completion_list) c.argument( diff --git a/src/aks-preview/azext_aks_preview/commands.py b/src/aks-preview/azext_aks_preview/commands.py index 52c3cfd0b95..9c0612ed72a 100644 --- a/src/aks-preview/azext_aks_preview/commands.py +++ b/src/aks-preview/azext_aks_preview/commands.py @@ -168,7 +168,7 @@ def load_command_table(self, _): ) g.custom_command("upgrade", "aks_upgrade", supports_no_wait=True) g.custom_command("scale", "aks_scale", supports_no_wait=True) - g.command("delete", "begin_delete", supports_no_wait=True, confirmation=True) + g.custom_command("delete", "aks_delete", supports_no_wait=True, confirmation=True) g.custom_show_command( "show", "aks_show", table_transformer=aks_show_table_format ) diff --git a/src/aks-preview/azext_aks_preview/custom.py b/src/aks-preview/azext_aks_preview/custom.py index de53ffb9648..56ba1f3d077 100644 --- a/src/aks-preview/azext_aks_preview/custom.py +++ b/src/aks-preview/azext_aks_preview/custom.py @@ -1445,6 +1445,22 @@ def aks_show(cmd, client, resource_group_name, name, aks_custom_headers=None): return _remove_nulls([mc])[0] +def aks_delete(cmd, client, resource_group_name, name, no_wait=False, + if_match=None, if_none_match=None, ignore_pod_disruption_budget=None): + if if_none_match is not None: + logger.warning( + "The '--if-none-match' option is not applicable to delete operations and will be ignored." + ) + return sdk_no_wait( + no_wait, + client.begin_delete, + resource_group_name, + name, + if_match=if_match, + ignore_pod_disruption_budget=ignore_pod_disruption_budget, + ) + + # pylint: disable=unused-argument def aks_stop(cmd, client, resource_group_name, name, no_wait=False): instance = client.get(resource_group_name, name)