This topic describes how to mount a statically provisioned disk volume by using a persistent volume (PV) and a persistent volume claim (PVC).
Prerequisites
To mount a disk as a volume, you must first create the disk in the Elastic Compute Service (ECS) console. For more information, see Create a disk.Mount a statically provisioned disk volume by using a PV and a PVC
- Create a PV of the disk type. You can create a PV of the disk type in the Container Service for Kubernetes (ACK) console or by using a YAML file.
- Create a PV by using a YAML file.
- Create a file named disk-pv.yaml by using the following template:
apiVersion: v1 kind: PersistentVolume metadata: name: d-bp1j17ifxfasvts3**** labels: failure-domain.beta.kubernetes.io/zone: cn-hangzhou-b failure-domain.beta.kubernetes.io/region: cn-hangzhou spec: capacity: storage: 20Gi storageClassName: disk accessModes: - ReadWriteOnce flexVolume: driver: "alicloud/disk" fsType: "ext4" options: volumeId: "d-bp1j17ifxfasvts3****"
Note Thename
of the PV must be the same as the disk ID that is specified byvolumeId
. - Run the following command to create a PV:
kubectl apply -f disk-pv.yaml
- Create a file named disk-pv.yaml by using the following template:
- Create a PV in the ACK console.
- Log on to the ACK console.
- In the left-side navigation pane of the ACK console, click Clusters.
- On the Clusters page, find the cluster that you want to manage. Then, click the name of the cluster or click Details in the Actions column.
- In the left-side navigation pane of the details page, choose .
- In the upper-right corner of the Persistent Volumes page, click Create.
- In the Create PV dialog box, set the parameters.
Parameter Description PV Type In this example, Cloud Disk is selected. Volume Plug-in In this example, Flexvolume is selected. Access Mode By default, this parameter is set to ReadWriteOnce. Disk ID Select a mountable disk that is deployed in the same region and zone as your cluster. File System Type Select the file system type of the disk. Valid values: ext4, ext3, xfs, and vfat. Default value: ext4. Label Add labels to the PV. - After you complete the settings, click Create.
- Create a PV by using a YAML file.
- Create a PVC.
- Create a pod.