Mount a static persistent volume using a PVC
Mount a static persistent volume for a pod by binding an existing PV.
In the current Agile PaaS environment, AKS is not integrated with Alibaba Cloud NAS or cloud disks. To use storage features, you must install a third-party storage plugin.
Prerequisites
A storage class has been created.
An available cloud disk exists in the same tenant.
Create a static PV
Create a PV and bind it to an existing cloud disk. You can create the PV using a YAML file or the console.
The following is a sample YAML file:
apiVersion: v1
kind: PersistentVolume
metadata:
labels:
cafe.sofastack.io/diskId: d-zm0fd73z6tmf5j7pgbpe
name: pv-efficient
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 25Gi
csi:
driver: antcloud-csi
fsType: ext4
volumeAttributes:
storage_type: cloud_disk
volumeHandle: instance_test_efficiency
storageClassName: csi-disk-efficiencyParameters
Parameter Name | Description | Required | Notes |
cafe.sofastack.io/diskId | The ID of the Alibaba Cloud disk. The format is | Yes | You can find the disk ID in the Resource Management console under Elastic Compute Service > Storage & Snapshots > Disks. |
volumeAttributes | The properties of the disk. | Yes | These properties must follow the backend storage limits, such as the Alibaba Cloud disk limits. For both the csi-disk-ssd and csi-disk-efficiency storage classes, the minimum size is 20 GB. |
volumeHandle | The unique ID for the backend storage. You specify this ID. | Yes | - |
Create a PVC and bind it to the PV
You can create the PVC using a YAML file or the console.
The following is a sample YAML file:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: test-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 25Gi
storageClassName: csi-disk-efficiency
volumeName: pv-efficientThe `volumeName` field is required to specify the existing PV. For more information about the parameters, see Mount a dynamically provisioned volume using a PVC.
Use the PVC
You can use the PVC to mount a static data volume when you create a pod.
apiVersion: v1
kind: Pod
metadata:
name: pod-with-disk
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-pvcAfter the container starts, the pod status is Running:
# kubectl get pod
NAME READY STATUS RESTARTS AGE
pod-with-disk 1/1 Running 0 103s