Mount a dynamically provisioned volume using a PVC

Updated at:

You can mount a dynamically provisioned volume using a StorageClass. Before you begin, an AKS administrator must create a storage class.

Note

In the current Agile Platform as a Service (PaaS) base environment, AKS is not integrated with Alibaba Cloud NAS or cloud disk storage. To use storage features, you must install a third-party storage plugin.

Prerequisites

A storage class is created.

Create a persistent volume claim (PVC)

Create a PVC before you create the pod that will use it. After you create the PVC, a corresponding persistent volume (PV) is automatically created.

Example of a cloud disk PVC

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: test-pvc
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 25Gi
  storageClassName: csi-disk-efficiency # csi-disk-ssd

Parameters

Parameter name

Description

Required

Notes

accessModes

Read-only or Read-write

No

Only ReadWriteOnce is supported.

storage

The storage capacity.

Yes

Subject to backend storage limits. For more information, see Limits. For the csi-disk-ssd and csi-disk-efficiency storage classes, the minimum storage capacity is 20 Gi. Otherwise, the PV cannot be created and the PVC remains in the pending state.

storageClassName

The name of the storage class.

Yes

If you do not specify an existing name, the cloud disk cannot be created.

Example of a NAS PVC

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: test-pvc
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 25Gi
  storageClassName: csi-nas-capacity # or csi-nas-performance
Important

For NAS storage, the specified storage capacity is not enforced. It does not limit the amount of data that a container can write at runtime. This value is used only to match the PV and PVC during the binding process.

Parameters

Parameter name

Description

Required

Notes

accessModes

Read-only or read-write

No

Valid values: ReadWriteOnce and ReadWriteMany.

storage

The storage capacity.

Yes

Subject to backend storage limits, such as Alibaba Cloud NAS limits. The file system capacity limit is 1 PB for Performance NAS or 10 PB for Capacity NAS.

storageClassName

Storage class name

Yes

You must specify an existing name to create the cloud disk.

Use a PVC

You can use a PVC to mount a dynamically provisioned volume when you create a pod.

apiVersion: v1
kind: Pod
metadata:
  name: pod-with-nas
  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 starts, the pod status is Running:

# kubectl get pod
NAME            READY   STATUS    RESTARTS   AGE
pod-with-nas   1/1     Running   0          103s