In GKE, regional persistent disks provide multi-zonal volumes that replicate data between two zones within the same region. They can be consumed in the same way as standard persistent disks. In the event of a zonal outage or zonal cluster failure, Kubernetes is using the volume to failover workloads to the other zone. Regional persistent disks can be utilized to build highly available solutions for stateful workloads on GKE.



1. To showcase the configuration steps, we are first creating a regional GKE cluster that spans three zones in the us-central1 region.
gcloud container clusters create repd \
  --machine-type=n1-standard-1 \
  --region=us-central1 \
  --num-nodes=1


2. Now we can create the StorageClass define the zones of the regional disk. The zones listed in the StorageClass are matching the zones of the GKE cluster.
kubectl apply -f - <<EOF
       kind: StorageClass
      apiVersion: storage.k8s.io/v1
      metadata:
        name: repd-central1-a-b-c
      provisioner: kubernetes.io/gce-pd
      parameters:
        type: pd-standard
        replication-type: regional-pd
      EOF


3. As a next step we are creating a persistentvolumeclaim for our application.

kubectl apply -f - <<EOF
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: wp-repd-wordpress
  namespace: default
  labels:
    app: wp-repd-wordpress
    release: wp-repd
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 200Gi
  storageClassName: repd-central1-a-b-c
EOF


4. At this point we are ready to utilize the persistentvolumeclaim by an application. In this example I’m deploying wordpress using helm.
helm install wp-repd \
  --set smtpHost= --set smtpPort= --set smtpUser= \
  --set smtpPassword= --set smtpUsername= --set
      smtpProtocol= 
  --set persistence.storageClass=repd-central1-a-b-c \
  --set persistence.existingClaim=wp-repd-wordpress \
  --set persistence.accessMode=ReadOnlyMany \
  stable/wordpress
kubectl get pods
NAME    READY   STATUS    RESTARTS   AGE
wp-repd-mariadb-0         1/1     Running   0        55s
wp-repd-wordpress-976cf4cd5-qhhxc   1/1     Running   0          55s