Use Persistent Volume Claims (PVC)

Updated at:

After a PersistentVolumeClaim (PVC) is created, you can use the PVC when you create a pod.

Important

  • A cloud disk cannot be mounted across availability zones (AZs). Therefore, after a PVC of the volumeBindingMode: Immediate type is created, the pod/workload that uses the PVC must be prevented from running in the same AZ of the PV/PVC by using nodeSelector/nodeAffinity.

  • At present, LDC Hybrid Cloud (LHC) is not connected to Alibaba Cloud NAS or cloud disk storage. To use the storage feature, you must install third-party storage plug-ins.

Prerequisites

You have created a PVC. For more information, see Create a PVC.

Procedure

  1. Go to the Clusters page.

  2. Click the name of the target cluster to go to the Cluster Details page and click the Workload tab.

  3. In the left-side menu, click Pods, and then click Create Pods.

  4. In the input box that appears, enter the YAML content, and then click Submit.

    Example:

     apiVersion: v1
     kind:Pod
     metadata:
       name: pod-with-disk
    namespace:default
       labels:
         app: nginx
     spec:
       tolerations:
    - key: node.kubernetes.io/unreachable
         effect:NoSchedule
    operator:Exists
       automountServiceAccountToken:false
       containers:
    - name: busybox
         image: reg-cnsh-nf.cloud.alipay.com/library/busybox
         command:["sleep","3000"]
         ports:
    - containerPort:80
         volumeMounts:
    - name: data
             mountPath:"/data"
       volumes:
    - name: data
           persistentVolumeClaim:
             claimName: test-pvc

    After the container runs, the status of the pod changes to Running.

    # kubectl get pod
    NAME            READY   STATUS    RESTARTS   AGE
    pod-with-disk   1/1Running0103s