This page explains how to enable dynamic provisioning of Regional Persistent Disks and how to provision them manually.
Regional Persistent Disks
As with regular persistent disks, regional persistent disks can be dynamically provisioned as needed or manually provisioned in advance by the cluster administrator.
To enable dynamic provisioning of regional persistent disks, create a
StorageClass with the
zones parameters. For example, the following manifest
describes a StorageClass that uses standard persistent disks and that
replicates data to the europe-west1-b and europe-west1-c zones:
kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: regionalpd-storageclass provisioner: kubernetes.io/gce-pd parameters: type: pd-standard replication-type: regional-pd zones: europe-west1-b, europe-west1-c
To create a PersistentVolumeClaim named "regional-pvc" with the
regionalpd-storageclass StorageClass, refer to the StorageClass
in the claim's manifest:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: regional-pvc namespace: testns spec: accessModes: - ReadWriteOnce resources: requests: storage: 200Gi storageClassName: regionalpd-storageclass
First, create a regional persistent disk. The following example creates a disk named "gce-disk-1" replicated to the europe-west1-b and europe-west1-c zones:
gcloud beta compute disks create \ gce-disk-1 \ --region europe-west1 \ --replica-zones europe-west1-b,europe-west1-c
You can then create a PersistentVolume that references the regional persistent disk, following the procedure described here.
Kubernetes automatically adds a label to
PersistentVolume objects that are backed by a regional persistent disk. The
label's key is
failure-domain.beta.kubernetes.io/zone and its value is
the two zones where the persistent disks are located. For example, a
PersistentVolume that is backed by regional persistent disk that replicates data
to europe-west1-b and europe-west1-c has this label added to it:
Naming persistent disks
Kubernetes cannot distinguish between zonal and regional persistent disks with the same name. As a workaround, ensure that persistent disks have unique names. This issue does not occur when using dynamically provisioned PDs.