共用方式為


在 Azure 容器儲存體中複製永續性磁碟區

您可在 Azure 容器儲存體中複製永續性磁碟區。 複製的磁碟區是現有永續性磁碟區的複本。 您僅可複製相同存放集區中相同大小的磁碟區。

必要條件

  • 本文需要最新版本 (2.35.0 或更新版本) 的 Azure CLI。 請參閱如何安裝 Azure CLI。 若您使用的是 Azure Cloud Shell,即已安裝最新版本。 如果您計劃在本機執行命令,而不是在 Azure Cloud Shell 中執行命令,請務必使用系統管理權限來執行這些命令。
  • 您將需要 Azure Kubernetes Service (AKS) 叢集,且叢集節點的節點集區至少包含三部虛擬機器 (VM),每個節點至少有四個虛擬 CPU (vCPU)。
  • 本文假設您已在 AKS 叢集上安裝 Azure 容器儲存體,而且您已使用 Azure 磁碟暫時磁碟 (本機儲存體) 建立存放集區和永續性磁碟宣告 (PVC)。 Azure 彈性 SAN 不支援調整磁碟區的大小。

複製磁碟區

請遵循下列指示複製勇續性磁碟區。

  1. 使用您慣用的文字編輯器來建立 YAML 資訊清單檔,例如 code acstor-clonevolume.yaml

  2. 貼上下列程式碼並儲存檔案。 內建儲存體類別支援磁碟區複製,因此針對 dataSource,請務必參考先前由 Azure 容器儲存體儲存體類別所建立的 PVC。 例如,如果您已建立 Azure 磁碟的 PVC,則可能稱為 azurediskpvc。 針對 storage,請指定原始 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. 套用 YAML 資訊清單檔以複製 PVC。

    kubectl apply -f acstor-clonevolume.yaml 
    

    您應該會看到如下所示的輸出:

    persistentvolumeclaim/pvc-acstor-cloning created
    
  4. 使用您慣用的文字編輯器來建立 YAML 資訊清單檔,例如 code acstor-pod.yaml

  5. 貼上下列程式碼並儲存檔案。 針對 claimName,請務必參考複製的 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. 套用 YAML 資訊清單檔以部署新 Pod。

    kubectl apply -f acstor-pod.yaml
    

    您應該會看到如下輸出:

    pod/fiopod2 created
    
  7. 檢查 Pod 是否正在執行,且永續性磁碟區宣告已成功繫結至 Pod:

    kubectl describe pod fiopod2
    kubectl describe pvc azurediskpvc
    

另請參閱