|
| 1 | +--- |
| 2 | + |
| 3 | +title: Create and use storage classes in AKS enabled by Arc (preview) |
| 4 | +description: Learn how to create and use storage classes in AKS enabled by Arc. |
| 5 | +author: sethmanheim |
| 6 | +ms.author: sethm |
| 7 | +ms.date: 11/12/2024 |
| 8 | +ms.topic: conceptual |
| 9 | +ms.custom: references_regions |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +# Create and use storage classes (preview) |
| 14 | + |
| 15 | +This article describes how to create and use Azure Arc-enabled storage classes for AKS on Azure Stack HCI 23H2. |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +To use the storage classes feature, you must have an AKS Arc cluster running, in the following currently available regions: |
| 20 | + |
| 21 | +- East US (eastus) |
| 22 | +- West Europe (westeurope) |
| 23 | +- Australia East (australiaeast) |
| 24 | +- Southeast Asia (southeastasia) |
| 25 | +- Central India (centralindia) |
| 26 | +- Canada Central (canadacentral) |
| 27 | +- Japan East (japaneast) |
| 28 | +- South Central US (southcentralus) |
| 29 | + |
| 30 | +If you want to use the storage classes feature with Azure CLI, you must also have Azure CLI installed and set up on your machine, and install the `k8s-runtime` extension using the following command: |
| 31 | + |
| 32 | +```azurecli |
| 33 | +az extension add --name k8s-runtime |
| 34 | +``` |
| 35 | + |
| 36 | +## [Azure portal](#tab/portal) |
| 37 | + |
| 38 | +During the preview, our publicly available portal extension only targets AKS Arc clusters and is behind the feature flag `managedstorageclass` of the `Microsoft_Azure_HybridCompute` portal extension. [Visit this Azure portal link](https://portal.azure.com/?Microsoft_Azure_HybridCompute_managedstorageclass=true) to open the portal and navigate to your AKS Arc cluster resource. |
| 39 | + |
| 40 | +### Enable the service |
| 41 | + |
| 42 | +Select your cluster, then select **Storage classes (preview)** from menu to enter the UI. Select **Enable service** to enable the service in your cluster. |
| 43 | + |
| 44 | +:::image type="content" source="media/create-storage-classes/enable-service.png" alt-text="Screenshot showing enable storage classes service on portal." lightbox="media/create-storage-classes/enable-service.png"::: |
| 45 | + |
| 46 | +It might take a few minutes to enable the service in your cluster. When it's ready, the UI looks similar to the following screenshot. Your storage classes are uploaded to the cloud: |
| 47 | + |
| 48 | +:::image type="content" source="media/create-storage-classes/storage-classes-summary.png" alt-text="Screenshot showing summary of storage classes on portal." lightbox="media/create-storage-classes/storage-classes-summary.png"::: |
| 49 | + |
| 50 | +## [Azure CLI](#tab/cli) |
| 51 | + |
| 52 | +To enable the service in your connected cluster, you must first get the resource ID for your connected cluster. Run the following command: |
| 53 | + |
| 54 | +```azurecli |
| 55 | +az k8s-runtime storage-class enable --resource-uri <connected cluster resource id> |
| 56 | +``` |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## List all storage classes in the cloud |
| 61 | + |
| 62 | +This section describes how to list all storage classes in the cloud using the portal, or CLI. |
| 63 | + |
| 64 | +### [Azure portal](#tab/portal) |
| 65 | + |
| 66 | +The previous UI shows all the storage classes in your connected cluster that are already synchronized to the cloud. |
| 67 | + |
| 68 | +### [Azure CLI](#tab/cli) |
| 69 | + |
| 70 | +You can get all storage class resources of an Arc-connected cluster using Azure CLI: |
| 71 | + |
| 72 | +```azurecli |
| 73 | +az k8s-runtime storage-class list --resource-uri <connecter cluster resource id> |
| 74 | +``` |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +## Create a storage class |
| 79 | + |
| 80 | +This section describes how to create a storage class using the Azure portal, or Azure CLI. |
| 81 | + |
| 82 | +### NFS |
| 83 | + |
| 84 | +#### [Azure portal](#tab/portal) |
| 85 | + |
| 86 | +When the service is ready, the **Create** button on the action bar becomes available. Select it, and a new blade to create a new storage class is displayed. |
| 87 | + |
| 88 | +:::image type="content" source="media/create-storage-classes/create-storage-class-portal.png" alt-text="Screenshot of portal blade showing create storage class." lightbox="media/create-storage-classes/create-storage-class-portal.png"::: |
| 89 | + |
| 90 | +To create an NFS storage class, select **NFS** from the **Type** dropdown under the **Storage Class Type** section, and then input the NFS source with format `<address>:<share>`. If you want to use the same directory for all persistent volumes provisioned for this storage class, input a subdirectory under the share in the **Sub Directory** textbox. If it's left empty, a new subdirectory under the share is created for each provisioned persistent volume. |
| 91 | + |
| 92 | +:::image type="content" source="media/create-storage-classes/create-storage-class-nfs.png" alt-text="Screenshot of portal blade showing create NFS storage class." lightbox="media/create-storage-classes/create-storage-class-nfs.png"::: |
| 93 | + |
| 94 | +If your AKS Arc instance doesn't have the built-in NFS CSI feature enabled, an error message is displayed, and you're unable to create an NFS storage class. [Follow these instructions](https://aka.ms/aks-arc-nfs-csi) to enable NFS CSI in your cluster, and then create the storage class again. |
| 95 | + |
| 96 | +:::image type="content" source="media/create-storage-classes/create-storage-class-no-csi-nfs.png" alt-text="Screenshot of portal showing error when CSI not enabled." lightbox="media/create-storage-classes/create-storage-class-no-csi-nfs.png"::: |
| 97 | + |
| 98 | +After you complete the form in the **Basics** tab, you can optionally specify advanced options under the **Advanced** tab. |
| 99 | + |
| 100 | +Select **Review + Create** at the bottom of the tab, wait for validation to complete, review the configuration for the storage class, and then select **Create** to create it. |
| 101 | + |
| 102 | +After the Azure Resource Manager deployment completes, a new storage class with specified name is created in the cluster. |
| 103 | + |
| 104 | +:::image type="content" source="media/create-storage-classes/storage-summary.png" alt-text="Screenshot of portal showing storage summary."::: |
| 105 | + |
| 106 | +#### [Azure CLI](#tab/cli) |
| 107 | + |
| 108 | +You can create a new SMB storage class using Azure CLI: |
| 109 | + |
| 110 | +```azurecli |
| 111 | +az k8s-runtime storage-class create ` |
| 112 | + --resource-uri <connected cluster resource id> ` |
| 113 | + --storage-class-name nfs-test ` |
| 114 | + --type-properties nfs.server="<server address>" ` |
| 115 | + --type-properties nfs.share="<share>" ` |
| 116 | + --type-properties nfs.subDir="/subdir" |
| 117 | +``` |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +### SMB |
| 122 | + |
| 123 | +#### [Azure portal](#tab/portal) |
| 124 | + |
| 125 | +Select **SMB** in the **Type** dropdown under the **Storage Class Type** section, and then input the required information: |
| 126 | + |
| 127 | +:::image type="content" source="media/create-storage-classes/create-smb.png" alt-text="Screenshot of portal showing create SMB storage class." lightbox="media/create-storage-classes/create-smb.png"::: |
| 128 | + |
| 129 | +If your AKS Arc instance doesn't have the built-in NFS CSI feature enabled, an error message is displayed, and you're unable to create an NFS storage class. [Follow these instructions](https://aka.ms/aks-arc-nfs-csi) to enable NFS CSI in your cluster, and then create the storage class again. |
| 130 | + |
| 131 | +#### [Azure CLI](#tab/cli) |
| 132 | + |
| 133 | +You can create an SMB storage class using Azure CLI: |
| 134 | + |
| 135 | +```azurecli |
| 136 | +az k8s-runtime storage-class create ` |
| 137 | + --resource-uri <connected cluster resource id> ` |
| 138 | + --storage-class-name smb-test ` |
| 139 | + --type-properties smb.source="<server address>" ` |
| 140 | + --type-properties smb.subDir="/subdir" |
| 141 | +``` |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +### AksArcDisk |
| 146 | + |
| 147 | +#### [Azure portal](#tab/portal) |
| 148 | + |
| 149 | +You can create [a storage class for a custom disk](https://aka.ms/aks-arc-custom-disk-storage-class) for AKS Arc. This type is only available for AKS Arc. A storage path is required for this type of storage class. You can select one with the provided selector, or input the storage path resource ID directly: |
| 150 | + |
| 151 | +:::image type="content" source="media/create-storage-classes/create-storage-class-aks-arc-disk.png" alt-text="Screenshot of portal showing create custom disk storage class." lightbox="media/create-storage-classes/create-storage-class-aks-arc-disk.png"::: |
| 152 | + |
| 153 | +#### [Azure CLI](#tab/cli) |
| 154 | + |
| 155 | +You can create a storage class for a custom disk using Azure CLI: |
| 156 | + |
| 157 | +```azurecli |
| 158 | +az k8s-runtime storage-class create ` |
| 159 | + --resource-uri <connected cluster resource id> ` |
| 160 | + --storage-class-name smb-test ` |
| 161 | + --type-properties aksarcdisk.storagePathId="<resource id for the storage path>" ` |
| 162 | + --type-properties aksarcdisk.fsType=ext4 |
| 163 | +``` |
| 164 | + |
| 165 | +--- |
| 166 | + |
| 167 | +## Update a storage class |
| 168 | + |
| 169 | +You can update some properties of a storage class using Azure CLI. See the following considerations when updating a storage class: |
| 170 | + |
| 171 | +- You can't change a storage class from one type to another type. |
| 172 | +- Changing most properties of a storage class results in deleting the original and re-creating a new one. However, updating some properties doesn't delete the original. These properties are called *in-place updatable*. To understand what properties you can update in-place, see the tables in the Reference section. |
| 173 | +- When you set the key name in `--type-properties`, use the property name directly without the `<storage class type>.` prefix. Properties that aren't part of the storage class type are ignored. |
| 174 | + |
| 175 | +```azurecli |
| 176 | +az k8s-runtime storage-class update ` |
| 177 | + --resource-uri <connected cluster resource id> ` |
| 178 | + --storage-class-name nfs-test ` |
| 179 | + --type-properties server=172.23.1.4 |
| 180 | +``` |
| 181 | + |
| 182 | +## Delete a storage class |
| 183 | + |
| 184 | +You can delete a storage class using the Azure portal or Azure CLI. |
| 185 | + |
| 186 | +### [Azure portal](#tab/portal) |
| 187 | + |
| 188 | +To delete storage classes from a cluster using the portal, select the storage classes to delete, then select **Delete** and confirm the action. |
| 189 | + |
| 190 | +:::image type="content" source="media/create-storage-classes/delete-portal.png" alt-text="Screenshot of portal showing delete storage classes." lightbox="media/create-storage-classes/delete-portal.png"::: |
| 191 | + |
| 192 | +### [Azure CLI](#tab/cli) |
| 193 | + |
| 194 | +You can delete a storage class using Azure CLI: |
| 195 | + |
| 196 | +```azurecli |
| 197 | +az k8s-runtime storage-class delete --resource-uri <connected resource id> --storage-class-name <storage class name> |
| 198 | +``` |
| 199 | + |
| 200 | +--- |
| 201 | + |
| 202 | +## Disable Storage Class service |
| 203 | + |
| 204 | +You can disable the Storage Class service using Azure CLI: |
| 205 | + |
| 206 | +```azurecli |
| 207 | +az k8s-runtime storage-class disable --resource-uri <resource uri> |
| 208 | +``` |
| 209 | + |
| 210 | +## Reference |
| 211 | + |
| 212 | +To specify a property when you create a storage class using Azure CLI, you must pass the `<storage class name type in lower cases>.<property name>=<property name>` value to a `--type-properties` command line parameter. You can pass multiple `--type-properties` command line parameters. It's not necessary to pass the `type` property to the CLI. For example, to set the `server` property in an NFS storage class, pass the `--type-properties nfs.server={server address}` value. |
| 213 | + |
| 214 | +When a storage class is updated, if all the properties that changed are updatable in-place (see the **In-place update** column in the following tables), the storage class isn't recreated. If any properties to update aren't updatable in-place, the storage class is deleted and re-created. |
| 215 | + |
| 216 | +### NFS |
| 217 | + |
| 218 | +| Property | Type | In-place update | Description | |
| 219 | +| -- | -- | -- | -- | |
| 220 | +| `type` | `NFS` | N/A | Specify this is an NFS type. | |
| 221 | +| `server` | `string` | No | NFS server address. | |
| 222 | +| `share` | `string` | No | NFS share. | |
| 223 | +| `subDir` | `string` \| `undefined` | No | Subdirectory under `share`. If the subdirectory doesn't exist, the driver creates it. | |
| 224 | +| `mountPermissions` | `string` \| `undefined` | No | Mounted folder permissions. Default is 0. If set as nonzero, the driver performs `chmod` after mount. | |
| 225 | +| `onDelete` | `Delete` \| `Retain` | No | The action to take when an NFS volume is deleted. Default is `Delete`. | |
| 226 | + |
| 227 | +### SMB |
| 228 | + |
| 229 | +| Property | Type | In-place update | Description | |
| 230 | +| -- | -- | -- | -- | |
| 231 | +| `type` | `SMB` | N/A | Specify this is an SMB type. | |
| 232 | +| `source` | `string` | No | SMB server source. | |
| 233 | +| `subDir` | `string` \| `undefined` | No | Subdirectory under share. If the subdirectory doesn't exist, the driver creates it. | |
| 234 | +| `username` | `string` \| `undefined` | **Yes** | Server username. | |
| 235 | +| `password` | `string` \| `undefined` (secret) | **Yes** | Server password. | |
| 236 | +| `domain` | `string` \| `undefined` | **Yes** | Server domain. | |
| 237 | + |
| 238 | +### AksArcDisk |
| 239 | + |
| 240 | +You can create a storage class that uses custom disks. This process is only for AKS Arc clusters. See [Create custom storage class for disks](container-storage-interface-disks.md?tabs=23H2#create-custom-storage-class-for-disks). |
| 241 | + |
| 242 | +| Property | type | In-place update | description | |
| 243 | +| -- | -- | -- | -- | |
| 244 | +| `type` | `AksArcDisk` | N/A | Specify this is the AksArcDisk type. | |
| 245 | +| `storagePathId` | `string` | No | The resource ID for the storage path. | |
| 246 | +| `fsType` | `string` \| `undefined` | No | `fsType` parameters for the storage class. If the storage class contains Linux workloads, set it to `ext4`. Otherwise, leave it undefined. | |
| 247 | + |
| 248 | +## Next steps |
| 249 | + |
| 250 | +[Storage class overview](storage-class-overview.md) |
0 commit comments