|
| 1 | +--- |
| 2 | +title: Abort an Azure Kubernetes Service (AKS) long running operation |
| 3 | +description: Learn how to terminate a long running operation on an Azure Kubernetes Service cluster at the node pool or cluster level. |
| 4 | +services: container-service |
| 5 | +ms.topic: article |
| 6 | +ms.date: 09/06/2022 |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +# Terminate a long running operation on an Azure Kubernetes Service (AKS) cluster |
| 11 | + |
| 12 | +Sometimes deployment or other processes running within pods on nodes in a cluster can run for periods of time longer than expected due to various reasons. While it's important to allow those processes to gracefully terminate when they're no longer needed, there are circumstances where you need to release control of node pools and clusters with long running operations using an *abort* command. |
| 13 | + |
| 14 | +AKS now supports aborting a long running operation, allowing you to take back control and run another operation seamlessly. This design is supported using the [Azure REST API](/rest/api/azure/) or the [Azure CLI](/cli/azure/). |
| 15 | + |
| 16 | +The abort operation supports the following scenarios: |
| 17 | + |
| 18 | +- If a long running operation is stuck or suspected to be in a bad state or failing, the operation can be aborted provided it's the last running operation on the Managed Cluster or agent pool. |
| 19 | +- If a long running operation is stuck or failing, that operation can be aborted. |
| 20 | +- An operation that was triggered in error can be aborted as long as the operation doesn't reach a terminal state first. |
| 21 | + |
| 22 | +## Before you begin |
| 23 | + |
| 24 | +This article assumes that you have an existing AKS cluster. If you need an AKS cluster, start with reviewing our guidance on how to design, secure, and operate an AKS cluster to support your production-ready workloads. For more information, see [AKS architecture guidance](/azure/architecture/reference-architectures/containers/aks-start-here). |
| 25 | + |
| 26 | +## Abort a long running operation |
| 27 | + |
| 28 | +### [Azure REST API](#tab/azure-rest) |
| 29 | + |
| 30 | +You can use the Azure REST API [Abort](/rest/api/aks/managed-clusters) operation to stop an operation against the Managed Cluster. |
| 31 | + |
| 32 | +The following example terminates a process for a specified agent pool. |
| 33 | + |
| 34 | +```rest |
| 35 | +/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedclusters/{resourceName}/agentPools/{agentPoolName}/abort |
| 36 | +``` |
| 37 | + |
| 38 | +The following example terminates a process for a specified managed cluster. |
| 39 | + |
| 40 | +```rest |
| 41 | +/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedclusters/{resourceName}/abort |
| 42 | +``` |
| 43 | + |
| 44 | +In the response, an HTTP status code of 204 is returned. |
| 45 | + |
| 46 | +### [Azure CLI](#tab/azure-cli) |
| 47 | + |
| 48 | +You can use the [az aks nodepool](/cli/azure/aks/nodepool) command with the `operation-abort` argument to abort an operation on a node pool or a managed cluster. |
| 49 | + |
| 50 | +The following example terminates an operation on a node pool on a specified cluster by its name and resource group that holds the cluster. |
| 51 | + |
| 52 | +```azurecli-interactive |
| 53 | +az aks nodepool operation-abort\ |
| 54 | +
|
| 55 | +--resource-group myResourceGroup \ |
| 56 | +
|
| 57 | +--cluster-name myAKSCluster \ |
| 58 | +``` |
| 59 | + |
| 60 | +The following example terminates an operation against a specified managed cluster its name and resource group that holds the cluster. |
| 61 | + |
| 62 | +```azurecli-interactive |
| 63 | +az aks operation-abort --name myAKSCluster --resource-group myResourceGroup |
| 64 | +``` |
| 65 | + |
| 66 | +In the response, an HTTP status code of 204 is returned. |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +The provisioning state on the managed cluster or agent pool should be **Canceled**. Use the REST API [Get Managed Clusters](/rest/api/aks/managed-clusters/get) or [Get Agent Pools](/rest/api/aks/agent-pools/get) to verify the operation. The provisioning state should update to **Canceled** within a few seconds of the abort request being accepted. Operation status of last running operation ID on the managed cluster/agent pool, which can be retrieved by performing a GET operation against the Managed Cluster or agent pool, should show a status of **Canceling**. |
| 71 | + |
| 72 | +## Next steps |
| 73 | + |
| 74 | +Learn more about [Container insights](../azure-monitor/containers/container-insights-overview.md) to understand how it helps you monitor the performance and health of your Kubernetes cluster and container workloads. |
0 commit comments