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:
A cluster administrator creates a PV that references the existing disk.
A developer creates a PVC. Kubernetes binds the PVC to the PV automatically when
storageClassNameandaccessModesmatch between the two.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
Create
disk-pv.yamlusing the following template. Replaced-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:
Field Description Required 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 storageClassNamein 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 Apply the manifest:
kubectl apply -f disk-pv.yamlVerify the PV was created:
kubectl get pv d-bp1j17ifxfasvts3****The output should show a
STATUSofAvailable:NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS AGE d-bp1j17ifxfasvts3**** 20Gi RWO Retain Available disk 10s
Option 2: ACK console
Log on to the ACK console and click Clusters in the left-side navigation pane.
On the Clusters page, click the name of your cluster or click Details in the Actions column.
In the left-side navigation pane, choose Volumes > Persistent Volumes.
In the upper-right corner, click Create.
In the Create PV dialog, set the following parameters:
Parameter Description PV Type Select Cloud Disk Volume Plug-in Select Flexvolume Access Mode Defaults to ReadWriteOnce Disk ID Select the disk. It must be in the same region and zone as the cluster. File System Type Select the file system type. Valid values: ext4 (default), ext3, xfs, vfat Label (Optional) Add labels to the PV 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: 20GiApply the manifest:
kubectl apply -f disk-pvc.yamlVerify the PVC is bound to the PV:
kubectl get pvc pvc-diskThe STATUS column should show Bound:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvc-disk Bound d-bp1j17ifxfasvts3**** 20Gi RWO disk 5sCreate 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-diskApply the manifest:
kubectl apply -f disk-pod.yamlVerify the pod is running and the volume is mounted:
kubectl get pods -l app=nginxThe pod should show a STATUS of Running.