All Products
Search
Document Center

Container Service for Kubernetes:Mount a statically provisioned disk volume

Last Updated:Mar 25, 2026

When you have a pre-existing cloud disk, static provisioning lets you attach it to a pod as a persistent volume without relying on a storage class to create the disk automatically. You manually create a PersistentVolume (PV) that points to the disk, bind it to a PersistentVolumeClaim (PVC), and reference the PVC from a pod.

How it works

Static provisioning involves three stages:

  1. A cluster administrator creates a PV that references the existing disk.

  2. A developer creates a PVC. Kubernetes binds the PVC to the PV automatically when storageClassName and accessModes match between the two.

  3. A pod references the PVC as a volume. From the pod's perspective, the PVC is the volume — it has no direct knowledge of the underlying PV or disk.

Prerequisites

Before you begin, ensure that you have:

  • A cloud disk created in the Elastic Compute Service (ECS) console, in the same region and zone as your ACK cluster. For instructions, see Create an empty data disk.

Record the disk ID after creation. You will need it when creating the PV.

Create a PV

Create a PV that maps to your existing cloud disk. Two methods are available: a YAML file or the ACK console.

Option 1: YAML file

  1. Create disk-pv.yaml using the following template. Replace d-bp1j17ifxfasvts3**** with your disk ID, and update the zone and region labels to match where your disk is located.

    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****"

    Key fields in this manifest:

    FieldDescriptionRequired
    metadata.nameMust exactly match the disk ID set in volumeId. Kubernetes uses this to locate the physical disk.Yes
    metadata.labelsZone and region labels used for scheduling. Must match your disk's location.Yes
    spec.capacity.storageDisk size. Set this to match the actual size of your cloud disk.Yes
    spec.storageClassNameMust match the storageClassName in the PVC for binding to succeed.Yes
    spec.accessModesSet to ReadWriteOnce. Cloud disks support single-node read/write access only.Yes
    spec.flexVolume.fsTypeFile system type. Valid values: ext4 (default), ext3, xfs, vfat.No
    spec.flexVolume.options.volumeIdThe disk ID of your pre-existing cloud disk.Yes
  2. Apply the manifest:

    kubectl apply -f disk-pv.yaml
  3. Verify the PV was created:

    kubectl get pv d-bp1j17ifxfasvts3****

    The output should show a STATUS of Available:

    NAME                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   AGE
    d-bp1j17ifxfasvts3****     20Gi       RWO            Retain           Available           disk           10s

Option 2: ACK console

  1. Log on to the ACK console and click Clusters in the left-side navigation pane.

  2. On the Clusters page, click the name of your cluster or click Details in the Actions column.

  3. In the left-side navigation pane, choose Volumes > Persistent Volumes.

  4. In the upper-right corner, click Create.

  5. In the Create PV dialog, set the following parameters:

    ParameterDescription
    PV TypeSelect Cloud Disk
    Volume Plug-inSelect Flexvolume
    Access ModeDefaults to ReadWriteOnce
    Disk IDSelect the disk. It must be in the same region and zone as the cluster.
    File System TypeSelect the file system type. Valid values: ext4 (default), ext3, xfs, vfat
    Label(Optional) Add labels to the PV
  6. Click Create.

Create a PVC

Create disk-pvc.yaml. Kubernetes binds this PVC to the PV when storageClassName and accessModes match the values in the PV you created.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pvc-disk
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: disk
  resources:
    requests:
      storage: 20Gi

Apply the manifest:

kubectl apply -f disk-pvc.yaml

Verify the PVC is bound to the PV:

kubectl get pvc pvc-disk

The STATUS column should show Bound:

NAME       STATUS   VOLUME                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
pvc-disk   Bound    d-bp1j17ifxfasvts3****     20Gi       RWO            disk           5s

Create a pod

Create disk-pod.yaml. The manifest defines a headless Service and a StatefulSet. The pod references the PVC by name — from the pod's perspective, the PVC is the volume, with no direct knowledge of the underlying PV or disk. The PVC is mounted at /data inside the nginx container.

apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  ports:
  - port: 80
    name: web
  clusterIP: None
  selector:
    app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: "nginx"
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: pvc-disk
          mountPath: /data
      volumes:
        - name: pvc-disk
          persistentVolumeClaim:
            claimName: pvc-disk

Apply the manifest:

kubectl apply -f disk-pod.yaml

Verify the pod is running and the volume is mounted:

kubectl get pods -l app=nginx

The pod should show a STATUS of Running.