Skip to content

Commit 6d8d2d6

Browse files
committed
added managed cluster snapshot
1 parent ab81153 commit 6d8d2d6

File tree

2 files changed

+174
-0
lines changed

2 files changed

+174
-0
lines changed

articles/aks/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@
184184
href: cluster-configuration.md
185185
- name: Custom node configuration
186186
href: custom-node-configuration.md
187+
- name: Use ManagedClusterSnapshot
188+
href: managed-cluster-snapshot.md
187189
- name: Integrate ACR with an AKS cluster
188190
href: cluster-container-registry-integration.md
189191
- name: Use Vertical Pod Autoscaler (preview)
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
---
2+
title: Use ManagedClusterSnapshot to save and apply Azure Kubernetes Service (AKS) cluster configuration (preview)
3+
description: Learn how to use ManagedClusterSnapshot to save and apply Azure Kubernetes Service (AKS) cluster configuration
4+
author: nickomang
5+
ms.author: nickoman
6+
ms.service: container-service
7+
ms.topic: how-to
8+
ms.date: 10/03/2022
9+
ms.custom: template-how-to
10+
---
11+
12+
# Use ManagedClusterSnapshot to save and apply Azure Kubernetes Service cluster configuration (preview)
13+
14+
ManagedClusterSnapshot allows you to save configuration from an Azure Kubernetes Service (AKS) cluster as a snapshot, which can then be used to easily apply the configuration to other clusters. Currently, we snapshot the following properties:
15+
- `ManagedClusterSKU`
16+
- `EnableRbac`
17+
- `KubernetesVersion`
18+
- `LoadBalancerSKU`
19+
- `NetworkMode`
20+
- `NetworkPolicy`
21+
- `NetworkPlugin`
22+
23+
[!INCLUDE [preview features callout](./includes/preview/preview-callout.md)]
24+
25+
## Prerequisite
26+
27+
- An Azure subscription. If you don't have an Azure subscription, you can create a [free account](https://azure.microsoft.com/free).
28+
- The latest version of the [Azure CLI](/cli/azure/install-azure-cli) installed.
29+
- Your cluster must be running successfully.
30+
- Your cluster must have been created with the `AddonManagerV2Preview` and `CSIControllersV2Preview` custom header feature values:
31+
```azurecli
32+
az aks create -g $RESOURCE_GROUP -n $CLUSTER_NAME --aks-custom-headers AKSHTTPCustomFeatures=AddonManagerV2Preview,AKSHTTPCustomFeatures=CSIControllersV2Preview
33+
```
34+
35+
### Install the `aks-preview` Azure CLI extension
36+
37+
Install the latest version of the `aks-preview` Azure CLI extension using the following command:
38+
39+
```azurecli
40+
az extension add --upgrade --name aks-preview
41+
```
42+
43+
### Register the `ManagedClusterSnapshotPreview` feature flag
44+
45+
To use the KEDA, you must enable the `ManagedClusterSnapshotPreview` feature flag on your subscription.
46+
47+
```azurecli
48+
az feature register --name ManagedClusterSnapshotPreview --namespace Microsoft.ContainerService
49+
```
50+
51+
You can check on the registration status by using the `az feature list` command:
52+
53+
```azurecli-interactive
54+
az feature list -o table --query "[?contains(name, 'Microsoft.ContainerService/ManagedClusterSnapshotPreview')].{Name:name,State:properties.state}"
55+
```
56+
57+
When ready, refresh the registration of the *Microsoft.ContainerService* resource provider by using the `az provider register` command:
58+
59+
```azurecli-interactive
60+
az provider register --namespace Microsoft.ContainerService
61+
```
62+
63+
## Take a snapshot of your cluster
64+
65+
To begin, get the `id` of the cluster you want to take a snapshot of using `az aks show`:
66+
67+
```azurecli-interactive
68+
az aks show -g $RESOURCE_GROUP -n $CLUSTER_NAME
69+
```
70+
71+
Using the `id` you just obtained, create a snapshot using `az aks snapshot create`:
72+
73+
```azurecli-interactive
74+
az aks snapshot create -g $RESOURCE_GROUp -n snapshot1 --cluster-id $CLUSTER_ID
75+
```
76+
77+
Your output will look similar to the following example:
78+
79+
```json
80+
{
81+
"creationData": {
82+
"sourceResourceId": $CLUSTER_ID
83+
},
84+
"id": "/subscriptions/$SUBSCRIPTION/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.ContainerService/managedclustersnapshots/snapshot1",
85+
"location": "eastus2",
86+
"managedClusterPropertiesReadOnly": {
87+
"enableRbac": true,
88+
"kubernetesVersion": "1.22.6",
89+
"networkProfile": {
90+
"loadBalancerSku": "Standard",
91+
"networkMode": null,
92+
"networkPlugin": "kubenet",
93+
"networkPolicy": null
94+
},
95+
"sku": {
96+
"name": "Basic",
97+
"tier": "Paid"
98+
}
99+
},
100+
"name": "snapshot1",
101+
"resourceGroup": $RESOURCE_GROUP,
102+
"snapshotType": "ManagedCluster",
103+
"systemData": {
104+
"createdAt": "2022-04-21T00:47:49.041399+00:00",
105+
"createdBy": "[email protected]",
106+
"createdByType": "User",
107+
"lastModifiedAt": "2022-04-21T00:47:49.041399+00:00",
108+
"lastModifiedBy": "[email protected]",
109+
"lastModifiedByType": "User"
110+
},
111+
"tags": null,
112+
"type": "Microsoft.ContainerService/ManagedClusterSnapshots"
113+
}
114+
```
115+
116+
## View a snapshot
117+
118+
To list all available snapshots, use the `az aks snapshot list` command:
119+
120+
```azurecli-interactive
121+
az aks snapshot list -g $RESOURCE_GROUP
122+
```
123+
124+
To view details for an individual snapshot, reference it by name in the `az aks snapshot show command`. For example, to view the snapshot `snapshot1` created in the steps above:
125+
126+
```azurecli-interactive
127+
az aks snapshot show -g $RESOURCE_GROUp -n snapshot1 -o table
128+
```
129+
130+
Your output will look similar to the following example:
131+
132+
```bash
133+
Name Location ResourceGroup Sku EnableRbac KubernetesVersion NetworkPlugin LoadBalancerSku
134+
--------- ---------- --------------- ----- ------------ ------------------- --------------- -----------------
135+
snapshot1 eastus2 qizhe-rg Paid True 1.22.6 kubenet Standard
136+
```
137+
138+
## Delete a snapshot
139+
140+
Removing a snapshot can be done by referencing the snapshot's name in the `az aks snapshot delete` command. For example, to delete the snapshot `snapshot1` created in the above steps:
141+
142+
```azurecli-interactive
143+
az aks snapshot delete -g $RESOURCE_GROUP -n snapshot1
144+
```
145+
146+
## Create a cluster from a snapshot
147+
148+
New AKS clusters can be created based on the configuration captured in a snapshot. To do so, first obtain the `id` of the desired snapshot. Next, use `az aks create`, using the snapshot's `id` with the `--cluster-snapshot-id` flag. Be sure to include the `addonManagerV2` and `CSIControllersV2Preview` feature flag custom header values. For example:
149+
150+
```azurecli-interactive
151+
az aks create -g $RESOURCE_GROUP -n aks-from-snapshot --cluster-snapshot-id "/subscriptions/$SUBSCRIPTION/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.ContainerService/managedclustersnapshots/snapshot1" --aks-custom-headers AKSHTTPCustomFeatures=AddonManagerV2Preview,AKSHTTPCustomFeatures=CSIControllersV2Preview
152+
```
153+
154+
> [!NOTE]
155+
> The cluster can be created with other allowed parameters that are not captured in the snapshot, such as `vm-sku-size` or `--node-count`. However, no configuration arguments for parameters that are part of the snapshot should be included. If the values passed in these arguments differs from the snapshot's values, cluster creation will fail.
156+
157+
## Update or upgrade a cluster using a snapshot
158+
159+
Clusters can also be updated and upgraded while using a snapshot by using the snapshot's `id` with the `--cluster-snapshot-id` flag:
160+
161+
162+
```azurecli-interactive
163+
az aks update -g $RESOURCE_GROUP -n aks-from-snapshot --cluster-snapshot-id "/subscriptions/$SUBSCRIPTION/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.ContainerService/managedclustersnapshots/snapshot1" --aks-custom-headers AKSHTTPCustomFeatures=AddonManagerV2Preview,AKSHTTPCustomFeatures=CSIControllersV2Preview
164+
```
165+
166+
167+
```azurecli-interactive
168+
az aks upgrade -g $RESOURCE_GROUP -n aks-from-snapshot --cluster-snapshot-id "/subscriptions/$SUBSCRIPTION/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.ContainerService/managedclustersnapshots/snapshot1" --aks-custom-headers AKSHTTPCustomFeatures=AddonManagerV2Preview,AKSHTTPCustomFeatures=CSIControllersV2Preview
169+
```
170+
171+
## Next steps
172+
- Learn [how to use node pool snapshots](./node-pool-snapshot.md)

0 commit comments

Comments
 (0)