Skip to content

Commit a5989cb

Browse files
author
naman-msft
committed
updated ada to v2
1 parent c6f35bc commit a5989cb

File tree

7 files changed

+734
-170
lines changed

7 files changed

+734
-170
lines changed

scripts/attempt_1_success.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
---
2+
title: Stop and start an Azure Kubernetes Service (AKS) cluster
3+
description: Learn how to stop and start an Azure Kubernetes Service (AKS) cluster.
4+
ms.topic: how-to
5+
ms.date: 07/01/2024
6+
author: palma21
7+
ms.author: palma21
8+
ms.custom: innovation-engine, aks, devx-track-azurecli
9+
---
10+
11+
# Stop and start an Azure Kubernetes Service (AKS) cluster
12+
13+
You may not need to continuously run your Azure Kubernetes Service (AKS) workloads. For example, you may have a development cluster that you only use during business hours. This means there are times where your cluster might be idle, running nothing more than the system components. You can reduce the cluster footprint by [scaling all `User` node pools to 0](scale-cluster.md#scale-user-node-pools-to-0), but your [`System` pool](use-system-pools.md) is still required to run the system components while the cluster is running.
14+
15+
To better optimize your costs during these periods, you can turn off, or stop, your cluster. This action stops your control plane and agent nodes, allowing you to save on all the compute costs, while maintaining all objects except standalone pods. The cluster state is stored for when you start it again, allowing you to pick up where you left off.
16+
17+
> [!CAUTION]
18+
> Stopping your cluster deallocates the control plane and releases the capacity. In regions experiencing capacity constraints, customers may be unable to start a stopped cluster. We do not recommend stopping mission critical workloads for this reason.
19+
20+
> [!NOTE]
21+
> AKS start operations will restore all objects from ETCD with the exception of standalone pods with the same names and ages. meaning that a pod's age will continue to be calculated from its original creation time. This count will keep increasing over time, regardless of whether the cluster is in a stopped state.
22+
23+
24+
## Before you begin
25+
26+
This article assumes you have an existing AKS cluster. If you need an AKS cluster, you can create one using [Azure CLI][aks-quickstart-cli], [Azure PowerShell][aks-quickstart-powershell], or the [Azure portal][aks-quickstart-portal].
27+
28+
### About the cluster stop/start feature
29+
30+
When using the cluster stop/start feature, the following conditions apply:
31+
32+
- This feature is only supported for Virtual Machine Scale Set backed clusters.
33+
- You can't stop clusters which use the [Node Autoprovisioning (NAP)](node-autoprovision.md) feature.
34+
- The cluster state of a stopped AKS cluster is preserved for up to 12 months. If your cluster is stopped for more than 12 months, you can't recover the state. For more information, see the [AKS support policies](support-policies.md).
35+
- You can only perform start or delete operations on a stopped AKS cluster. To perform other operations, like scaling or upgrading, you need to start your cluster first.
36+
- If you provisioned PrivateEndpoints linked to private clusters, they need to be deleted and recreated again when starting a stopped AKS cluster.
37+
- Because the stop process drains all nodes, any standalone pods (i.e. pods not managed by a Deployment, StatefulSet, DaemonSet, Job, etc.) will be deleted.
38+
- When you start your cluster back up, the following behavior is expected:
39+
- The IP address of your API server may change.
40+
- If you're using cluster autoscaler, when you start your cluster, your current node count may not be between the min and max range values you set. The cluster starts with the number of nodes it needs to run its workloads, which isn't impacted by your autoscaler settings. When your cluster performs scaling operations, the min and max values will impact your current node count, and your cluster will eventually enter and remain in that desired range until you stop your cluster.
41+
42+
## Stop an AKS cluster
43+
44+
### [Azure CLI](#tab/azure-cli)
45+
46+
1. Use the [`az aks stop`][az-aks-stop] command to stop a running AKS cluster, including the nodes and control plane. The following example stops a cluster named *myAKSCluster*:
47+
48+
```bash
49+
export AKS_NAME="myAKSCluster"
50+
export AKS_RG="myResourceGroup"
51+
az aks stop --name $AKS_NAME --resource-group $AKS_RG
52+
```
53+
54+
2. Verify your cluster has stopped using the [`az aks show`][az-aks-show] command and confirming the `powerState` shows as `Stopped`.
55+
56+
```bash
57+
az aks show --name $AKS_NAME --resource-group $AKS_RG --query "{powerState:powerState.code, provisioningState:provisioningState, nodeResourceGroup:nodeResourceGroup, resourceGroup:resourceGroup}"
58+
```
59+
60+
Results:
61+
62+
<!-- expected_similarity=0.3 -->
63+
64+
```output
65+
{
66+
"nodeResourceGroup": "MC_myResourceGroup_myAKSCluster_xxxxx",
67+
"powerState": "Stopped",
68+
"provisioningState": "Succeeded",
69+
"resourceGroup": "myResourceGroup"
70+
}
71+
```
72+
73+
If the `provisioningState` shows `Stopping`, your cluster hasn't fully stopped yet.
74+
75+
### [Azure PowerShell](#tab/azure-powershell)
76+
77+
1. Use the [`Stop-AzAksCluster`][stop-azakscluster] cmdlet to stop a running AKS cluster, including the nodes and control plane. The following example stops a cluster named *myAKSCluster*:
78+
79+
```azurepowershell-interactive
80+
Stop-AzAksCluster -Name myAKSCluster -ResourceGroupName myResourceGroup
81+
```
82+
83+
2. Verify your cluster has stopped using the [`Get-AzAksCluster`][get-azakscluster] cmdlet and confirming the `ProvisioningState` shows as `Succeeded`.
84+
85+
```azurepowershell-interactive
86+
Get-AzAKSCluster -Name myAKSCluster -ResourceGroupName myResourceGroup
87+
```
88+
89+
Your output should look similar to the following condensed example output:
90+
91+
```Output
92+
ProvisioningState : Succeeded
93+
MaxAgentPools : 100
94+
KubernetesVersion : 1.20.7
95+
...
96+
```
97+
98+
If the `ProvisioningState` shows `Stopping`, your cluster hasn't fully stopped yet.
99+
100+
---
101+
102+
> [!IMPORTANT]
103+
> If you're using [pod disruption budgets](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/), the stop operation can take longer, as the drain process will take more time to complete.
104+
105+
## Start an AKS cluster
106+
107+
> [!CAUTION]
108+
> After utilizing the start/stop feature on AKS, it is essential to wait 15-30 minutes before restarting your AKS cluster. This waiting period is necessary because it takes several minutes for the relevant services to fully stop. Attempting to restart your cluster during this process can disrupt the shutdown process and potentially cause issues with the cluster or its workloads.
109+
110+
### [Azure CLI](#tab/azure-cli)
111+
112+
1. Use the [`az aks start`][az-aks-start] command to start a stopped AKS cluster. The cluster restarts with the previous control plane state and number of agent nodes. The following example starts a cluster named *myAKSCluster*:
113+
114+
```bash
115+
az aks start --name $AKS_NAME --resource-group $AKS_RG
116+
```
117+
118+
2. Verify your cluster has started using the [`az aks show`][az-aks-show] command and confirming the `powerState` shows `Running`.
119+
120+
```bash
121+
az aks show --name $AKS_NAME --resource-group $AKS_RG --query "{powerState:powerState.code, provisioningState:provisioningState, nodeResourceGroup:nodeResourceGroup, resourceGroup:resourceGroup}"
122+
```
123+
124+
Results:
125+
126+
<!-- expected_similarity=0.3 -->
127+
128+
```output
129+
{
130+
"nodeResourceGroup": "MC_myResourceGroup_myAKSCluster_xxxxx",
131+
"powerState": "Running",
132+
"provisioningState": "Succeeded",
133+
"resourceGroup": "myResourceGroup"
134+
}
135+
```
136+
137+
If the `provisioningState` shows `Starting`, your cluster hasn't fully started yet.
138+
139+
### [Azure PowerShell](#tab/azure-powershell)
140+
141+
1. Use the [`Start-AzAksCluster`][start-azakscluster] cmdlet to start a stopped AKS cluster. The cluster restarts with the previous control plane state and number of agent nodes. The following example starts a cluster named *myAKSCluster*:
142+
143+
```azurepowershell-interactive
144+
Start-AzAksCluster -Name myAKSCluster -ResourceGroupName myResourceGroup
145+
```
146+
147+
2. Verify your cluster has started using the [`Get-AzAksCluster`][get-azakscluster] cmdlet and confirming the `ProvisioningState` shows `Succeeded`.
148+
149+
```azurepowershell-interactive
150+
Get-AzAksCluster -Name myAKSCluster -ResourceGroupName myResourceGroup
151+
```
152+
153+
Your output should look similar to the following condensed example output:
154+
155+
```Output
156+
ProvisioningState : Succeeded
157+
MaxAgentPools : 100
158+
KubernetesVersion : 1.20.7
159+
...
160+
```
161+
162+
If the `ProvisioningState` shows `Starting`, your cluster hasn't fully started yet.
163+
164+
---
165+
166+
## Next steps
167+
168+
- To learn how to scale `User` pools to 0, see [Scale `User` pools to 0](scale-cluster.md#scale-user-node-pools-to-0).
169+
- To learn how to save costs using Spot instances, see [Add a spot node pool to AKS](spot-node-pool.md).
170+
- To learn more about the AKS support policies, see [AKS support policies](support-policies.md).
171+
172+
<!-- LINKS - external -->
173+
174+
<!-- LINKS - internal -->
175+
[aks-quickstart-cli]: ./learn/quick-kubernetes-deploy-cli.md
176+
[aks-quickstart-portal]: ./learn/quick-kubernetes-deploy-portal.md
177+
[aks-quickstart-powershell]: ./learn/quick-kubernetes-deploy-powershell.md
178+
[az-aks-show]: /cli/azure/aks#az_aks_show
179+
[stop-azakscluster]: /powershell/module/az.aks/stop-azakscluster
180+
[get-azakscluster]: /powershell/module/az.aks/get-azakscluster
181+
[start-azakscluster]: /powershell/module/az.aks/start-azakscluster
182+
[az-aks-stop]: /cli/azure/aks#az_aks_stop
183+
[az-aks-start]: /cli/azure/aks#az_aks_start

0 commit comments

Comments
 (0)