Back to posts

HyperDisk Balanced High Availability for Multi-AZ GKE

Read the full guide on docs.beyondyou.my.id
gcpgkekuberneteshyperdiskmulti-azstoragestatefulset

HyperDisk Balanced High Availability for Multi-AZ GKE

Table of Contents

SectionTopicDescription
01Why HyperDisk HAThe problem with single-zone persistent disks.
02ArchitectureHow HyperDisk HA replicates across zones.
03StorageClass ConfigurationProvisioner, parameters, and allowed topologies.
04StatefulSet IntegrationUsing HyperDisk HA with stateful workloads.
05Performance TuningIOPS and throughput provisioning.
06Disk Type ComparisonHyperDisk HA vs Balanced vs Extreme vs pd-ssd.

1. Why HyperDisk HA

Standard GKE persistent volumes are zone-scoped. If a zone goes down, pods in that zone lose access to their disks — even if the pod is rescheduled to another zone.

Disk TypeZone ScopeCross-ZoneFailure Impact
pd-standardSingle zoneNoFull data loss if zone fails
pd-ssdSingle zoneNoFull data loss if zone fails
pd-balancedSingle zoneNoFull data loss if zone fails
hyperdisk-balanced-high-availabilityMulti-zoneYesSurvives zone failure

The Multi-AZ Problem

graph TB
    subgraph ZONE_A["Zone A"]
        pod_a["Pod A"]
        disk_a["pd-ssd\n(Zone A only)"]
    end
    subgraph ZONE_B["Zone B"]
        pod_b["Pod B\n(can't mount disk)"]
    end

    pod_a --> disk_a
    pod_b -.->|"FAILS:\nzone mismatch"| disk_a

HyperDisk HA solves this by replicating data across two zones — the volume is available in both, and a pod in either zone can mount it.


2. Architecture

HyperDisk Balanced High Availability replicates data synchronously across two zones within a region.

graph LR
    subgraph ZONE_A["Zone A"]
        primary["Primary Replica"]
    end
    subgraph ZONE_B["Zone B"]
        secondary["Secondary Replica"]
    end

    primary <-->|"synchronous\nreplication"| secondary
    pod_a["Pod in Zone A"] --> primary
    pod_b["Pod in Zone B"] --> secondary

How It Works

AspectDetail
ReplicationSynchronous, cross-zone
ConsistencyStrong — writes acknowledged after both replicas confirm
FailoverAutomatic — GKE remounts in surviving zone
RPO0 (no data loss on zone failure)
RTOSeconds (automatic remount)

Zone Affinity

The StorageClass uses allowedTopologies to restrict provisioning to two specific zones:

allowedTopologies:
- matchLabelExpressions:
  - key: topology.gke.io/zone
    values:
    - [zone-1]
    - [zone-2]

This ensures the volume is only created where it can replicate — the CSI driver handles zone selection within the allowed list.


3. StorageClass Configuration

Full StorageClass

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: [storage-class-name]-ha-storage
provisioner: pd.csi.storage.gke.io
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
  type: hyperdisk-balanced-high-availability
  provisioned-throughput-on-create: "250Mi"
  provisioned-iops-on-create: "7000"
allowedTopologies:
- matchLabelExpressions:
  - key: topology.gke.io/zone
    values:
    - [zone-1]
    - [zone-2]

Field Breakdown

FieldValuePurpose
provisionerpd.csi.storage.gke.ioGKE CSI driver for PersistentDisk
volumeBindingModeWaitForFirstConsumerDelay binding until pod is scheduled
allowVolumeExpansiontrueAllow kubectl patch to resize
typehyperdisk-balanced-high-availabilityMulti-zone HyperDisk
provisioned-throughput-on-create250MiRead/write throughput cap
provisioned-iops-on-create7000IOPS cap

Why WaitForFirstConsumer

ModeBehaviorRisk
ImmediateVolume created in first available zoneMay not match pod’s zone
WaitForFirstConsumerVolume created in pod’s zoneNone — zone-aware binding

With HyperDisk HA, WaitForFirstConsumer ensures the volume is provisioned in the zone where the pod actually runs — and replicates to the paired zone.


4. StatefulSet Integration

HyperDisk HA is designed for stateful workloads that must survive zone failures.

StatefulSet with HyperDisk HA

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: [environment]-[app_name]
  namespace: [namespace]
  labels:
    app: [app_name]
    env: [environment]
    team: [team_name]
    app.kubernetes.io/name: [app_name]
    app.kubernetes.io/instance: [environment]-[app_name]
    app.kubernetes.io/component: [component_name]
    app.kubernetes.io/part-of: [Company/Project]
    app.kubernetes.io/managed-by: DevOpsTeam
spec:
  serviceName: [app_name]
  replicas: 2
  selector:
    matchLabels:
      app: [app_name]
  template:
    metadata:
      labels:
        app: [app_name]
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchLabels:
                  app: [app_name]
              topologyKey: "kubernetes.io/hostname"
      containers:
      - name: [app_name]
        image: [image]
        ports:
        - containerPort: [port]
        volumeMounts:
        - name: data
          mountPath: /data
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: ["ReadWriteOnce"]
      storageClassName: [storage-class-name]-ha-storage
      resources:
        requests:
          storage: 50Gi

Pod Anti-Affinity

PolicyConfigEffect
requiredDuringSchedulingIgnoredDuringExecutiontopologyKey: hostnameEach pod on a different node

This ensures the two replicas run on different nodes — combined with HyperDisk HA, you get node-level + zone-level redundancy.

What Happens on Zone Failure

sequenceDiagram
    participant Zone_A as Zone A (Down)
    participant GKE
    participant Zone_B as Zone B (Up)
    participant Disk as HyperDisk HA

    Note over Zone_A: Zone A fails
    GKE->>GKE: Detect zone failure
    GKE->>Zone_B: Reschedule pod
    Zone_B->>Disk: Mount volume (secondary replica)
    Disk-->>Zone_B: Volume ready
    Zone_B->>Zone_B: Pod resumes with data intact

5. Performance Tuning

HyperDisk HA allows you to provision IOPS and throughput independently.

Provisioned Parameters

ParameterValueRangePurpose
provisioned-iops-on-create70001200–120,000Read/write operations per second
provisioned-throughput-on-create250Mi100–2,400 MiB/sRead/write throughput

Workload Profiles

WorkloadIOPSThroughputRationale
Database (OLTP)10,000–50,000250–500 MiB/sHigh random I/O, moderate sequential
Analytics (OLAP)5,000–10,000500–1,000 MiB/sSequential scans, large reads
Cache (Redis)12,000–70,000250 MiB/sHigh IOPS, low throughput
Media processing5,0001,000–2,000 MiB/sLarge sequential I/O

Resizing After Creation

# Resize the PVC
kubectl patch pvc data-[app_name]-0 -n [namespace] \
  --type merge \
  -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'

# Verify resize
kubectl get pvc -n [namespace]

Note: You can increase size but not decrease. IOPS and throughput are set at creation and cannot be changed later.


6. Disk Type Comparison

Featurepd-standardpd-ssdpd-balancedHyperDisk BalancedHyperDisk Balanced HA
MediaHDDSSDSSDSSDSSD
Zone scopeSingleSingleSingleSingleMulti-zone
Max IOPS15,000100,00080,000120,000120,000
Max throughput300 MiB/s1,200 MiB/s1,200 MiB/s2,400 MiB/s2,400 MiB/s
Volume size10 GiB–64 TiB10 GiB–64 TiB10 GiB–64 TiB10 GiB–64 TiB10 GiB–64 TiB
Cross-zoneNoNoNoNoYes
Best forBulk storage, logsGeneral workloadsMost workloadsHigh-perf databasesStateful HA workloads

Cost Estimation

Disk Type$/GB/month (approx)HA Premium
pd-standard$0.04N/A
pd-ssd$0.17N/A
pd-balanced$0.10N/A
HyperDisk Balanced$0.12N/A
HyperDisk Balanced HA$0.12+replication cost

HyperDisk HA costs include replication across two zones — check current pricing for exact rates.

When to Use HyperDisk HA

Use CaseRecommended DiskWhy
Log aggregationpd-standardCheap, durable, not latency-sensitive
CI/CD artifactspd-balancedGood balance of cost and performance
General workloadspd-ssdLow latency, high IOPS
Mission-critical databasesHyperDisk BalancedProvisioned IOPS/throughput
Stateful workloads requiring HAHyperDisk Balanced HASurvives zone failure

References