Course contentsShow
← Cloud and Infrastructure
Lesson 1313 of 2,98926. Kubernetes StorageFree lesson

StorageClass Topology Constraints

Using allowedTopologies to restrict volume provisioning to specific zones or regions for availability.

StorageClass Topology Constraints

What You'll Learn

You'll learn how to use allowedTopologies in StorageClasses to control where volumes are created, ensuring they're provisioned only in specific zones or regions for high availability.

The Core Problem

Imagine you have a Kubernetes cluster spanning multiple availability zones (like us-west-1a, us-west-1b, and us-west-1c). When a PersistentVolume is dynamically provisioned, it gets created in some zone—but what if your Pods are pinned to specific zones? If the volume lands in the wrong zone, your Pod can't attach to it because cloud volumes are typically zone-specific.

Topology constraints solve this by letting you define exactly where volumes can be created.

How allowedTopologies Works

The allowedTopologies field in a StorageClass acts like a whitelist. You specify topology keys (like zone labels) and their allowed values. The storage provisioner will only create volumes in locations matching those constraints.

Think of it like telling a pizza delivery service: "You can only deliver to these three neighborhoods." If someone orders from outside those areas, the order fails—keeping your system predictable and reliable.

Common Use Cases

  • Zone affinity: Restrict volumes to zones where your application runs
  • Regional compliance: Keep data in specific geographic regions
  • Cost optimization: Use cheaper zones for non-critical workloads
  • Disaster recovery: Separate primary and backup volumes across zones

Typical Topology Keys

  • topology.kubernetes.io/zone (availability zone)
  • topology.kubernetes.io/region (cloud region)

When you combine this with volume binding mode WaitForFirstConsumer, Kubernetes waits to see where your Pod is scheduled, then provisions the volume in a compatible topology—ensuring Pod and volume always align.

Key Takeaway: allowedTopologies in StorageClasses restricts dynamic volume provisioning to specific zones or regions, preventing topology mismatches and supporting high-availability architectures.