Muokkaa

Jaa


Clone persistent volumes in Azure Container Storage

You can clone persistent volumes in Azure Container Storage. 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.

Prerequisites

  • This article requires the latest version (2.35.0 or later) of the Azure CLI. See How to install the 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.
  • 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).
  • 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 or ephemeral disk (local storage). Azure Elastic SAN doesn't support resizing volumes.

Clone a volume

Follow the instructions below to clone a persistent volume.

  1. Use your favorite text editor to create a YAML manifest file such as code acstor-clonevolume.yaml.

  2. 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.

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: pvc-acstor-cloning
    spec:
      accessModes:
        - ReadWriteOnce
      storageClassName: acstor-azuredisk
      resources:
        requests:
          storage: 100Gi
      dataSource:
        kind: PersistentVolumeClaim
        name: azurediskpvc
    
  3. Apply the YAML manifest file to clone the PVC.

    kubectl apply -f acstor-clonevolume.yaml 
    

    You should see output similar to:

    persistentvolumeclaim/pvc-acstor-cloning created
    
  4. Use your favorite text editor to create a YAML manifest file such as code acstor-pod.yaml.

  5. Paste in the following code and save the file. For claimName, be sure to reference the cloned PVC.

    kind: Pod
    apiVersion: v1
    metadata:
      name: fiopod2
    spec:
      nodeSelector:
        acstor.azure.com/io-engine: acstor
      volumes:
        - name: azurediskpv
          persistentVolumeClaim:
            claimName: pvc-acstor-cloning
      containers:
        - name: fio
          image: nixery.dev/shell/fio
          args:
            - sleep
            - "1000000"
          volumeMounts:
            - mountPath: "/volume"
              name: azurediskpv
    
  6. Apply the YAML manifest file to deploy the new pod.

    kubectl apply -f acstor-pod.yaml
    

    You should see output similar to the following:

    pod/fiopod2 created
    
  7. Check that the pod is running and that the persistent volume claim has been bound successfully to the pod:

    kubectl describe pod fiopod2
    kubectl describe pvc azurediskpvc
    

See also