|
| 1 | +--- |
| 2 | +title: Clone persistent volumes in Azure Container Storage Preview |
| 3 | +description: Clone persistent volumes in Azure Container Storage Preview. You can only clone volumes of the same size that are in the same storage pool. |
| 4 | +author: khdownie |
| 5 | +ms.service: azure-container-storage |
| 6 | +ms.topic: how-to |
| 7 | +ms.date: 09/18/2023 |
| 8 | +ms.author: kendownie |
| 9 | +--- |
| 10 | + |
| 11 | +# Clone persistent volumes in Azure Container Storage Preview |
| 12 | +You can clone persistent volumes in [Azure Container Storage](container-storage-introduction.md). A cloned volume is a duplicate of an existing persistent volume. You can only clone volumes of the same size that are in the same storage pool. |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +- This article requires version 2.0.64 or later of the Azure CLI. See [How to install the Azure CLI](/cli/azure/install-azure-cli). If you're using Azure Cloud Shell, the latest version is already installed. If you plan to run the commands locally instead of in Azure Cloud Shell, be sure to run them with administrative privileges. |
| 17 | +- You'll need an Azure Kubernetes Service (AKS) cluster with a node pool of at least three virtual machines (VMs) for the cluster nodes, each with a minimum of four virtual CPUs (vCPUs). |
| 18 | +- This article assumes you've already installed Azure Container Storage on your AKS cluster, and that you've created a storage pool and persistent volume claim (PVC) using either [Azure Disks](use-container-storage-with-managed-disks.md) or [ephemeral disk (local storage)](use-container-storage-with-local-disk.md). Azure Elastic SAN Preview doesn't support resizing volumes. |
| 19 | + |
| 20 | +## Clone a volume |
| 21 | + |
| 22 | +Follow the instructions below to clone a persistent volume. |
| 23 | + |
| 24 | +1. Use your favorite text editor to create a YAML manifest file such as `code acstor-clonevolume.yaml`. |
| 25 | + |
| 26 | +1. Paste in the following code and save the file. A built-in storage class supports volume cloning, so for **dataSource** be sure to reference a PVC previously created by the Azure Container Storage storage class. For example, if you created the PVC for Azure Disks, it might be called `azurediskpvc`. For **storage**, specify the size of the original PVC. |
| 27 | + |
| 28 | + ```yml |
| 29 | + apiVersion: v1 |
| 30 | + kind: PersistentVolumeClaim |
| 31 | + metadata: |
| 32 | + name: pvc-acstor-cloning |
| 33 | + spec: |
| 34 | + accessModes: |
| 35 | + - ReadWriteOnce |
| 36 | + storageClassName: acstor-azuredisk |
| 37 | + resources: |
| 38 | + requests: |
| 39 | + storage: 100Gi |
| 40 | + dataSource: |
| 41 | + kind: PersistentVolumeClaim |
| 42 | + name: azurediskpvc |
| 43 | + ``` |
| 44 | +
|
| 45 | +1. Apply the YAML manifest file to clone the PVC. |
| 46 | + |
| 47 | + ```azurecli-interactive |
| 48 | + kubectl apply -f acstor-clonevolume.yaml |
| 49 | + ``` |
| 50 | + |
| 51 | + You should see output similar to: |
| 52 | + |
| 53 | + ```output |
| 54 | + persistentvolumeclaim/pvc-acstor-cloning created |
| 55 | + ``` |
| 56 | + |
| 57 | +1. Use your favorite text editor to create a YAML manifest file such as `code acstor-pod.yaml`. |
| 58 | + |
| 59 | +1. Paste in the following code and save the file. For **claimName**, be sure to reference the cloned PVC. |
| 60 | + |
| 61 | + ```yml |
| 62 | + kind: Pod |
| 63 | + apiVersion: v1 |
| 64 | + metadata: |
| 65 | + name: fiopod2 |
| 66 | + spec: |
| 67 | + nodeSelector: |
| 68 | + acstor.azure.com/io-engine: acstor |
| 69 | + volumes: |
| 70 | + - name: azurediskpv |
| 71 | + persistentVolumeClaim: |
| 72 | + claimName: pvc-acstor-cloning |
| 73 | + containers: |
| 74 | + - name: fio |
| 75 | + image: nixery.dev/shell/fio |
| 76 | + args: |
| 77 | + - sleep |
| 78 | + - "1000000" |
| 79 | + volumeMounts: |
| 80 | + - mountPath: "/volume" |
| 81 | + name: azurediskpv |
| 82 | + ``` |
| 83 | +
|
| 84 | +1. Apply the YAML manifest file to deploy the new pod. |
| 85 | + |
| 86 | + ```azurecli-interactive |
| 87 | + kubectl apply -f acstor-pod.yaml |
| 88 | + ``` |
| 89 | + |
| 90 | + You should see output similar to the following: |
| 91 | + |
| 92 | + ```output |
| 93 | + pod/fiopod2 created |
| 94 | + ``` |
| 95 | + |
| 96 | +1. Check that the pod is running and that the persistent volume claim has been bound successfully to the pod: |
| 97 | + |
| 98 | + ```azurecli-interactive |
| 99 | + kubectl describe pod fiopod2 |
| 100 | + kubectl describe pvc azurediskpvc |
| 101 | + ``` |
| 102 | + |
| 103 | + |
| 104 | +## See also |
| 105 | + |
| 106 | +- [What is Azure Container Storage?](container-storage-introduction.md) |
0 commit comments