12.12 Kubernetes StatefulSet Storage Management
Kubernetes StatefulSet manages persistent storage for stateful apps using PVs and PVCs, ensuring data reliability across pod restarts.
Kubernetes StatefulSet Storage Management is the operational practice of provisioning, monitoring, resizing, and eventually decommissioning the per-ordinal persistent storage that StatefulSet-managed workloads depend on, treating this storage as a durable asset requiring its own dedicated lifecycle management distinct from the more transient concerns of the Pods themselves.
Storage Class Selection
Matching Storage Characteristics to Workload Requirements
Choosing an appropriate storage class for a StatefulSet's volumeClaimTemplates requires matching the underlying storage medium's performance characteristics, such as input and output operations per second and latency, to the specific demands of the stateful application, since a mismatch can result in performance bottlenecks that manifest as application-level symptoms rather than obviously storage-related ones.
Considering Storage Class Availability Across Zones
For clusters spanning multiple availability zones, storage management includes verifying that the selected storage class supports provisioning in every zone where StatefulSet Pods might be scheduled, since a zone-restricted storage class could otherwise prevent an ordinal from being successfully scheduled and bound to its expected storage in an unexpected zone.
Capacity Planning and Resizing
Monitoring Per-Ordinal Storage Utilization
Because each ordinal's storage grows independently, storage management includes monitoring utilization on a per-ordinal basis rather than relying solely on an aggregate view, since one specific ordinal approaching capacity exhaustion could go unnoticed if only average or total storage consumption across the StatefulSet is being tracked.
Executing Volume Expansion When Supported
For storage classes supporting volume expansion, increasing the requested storage size in the volumeClaimTemplates and coordinating the corresponding expansion of already-provisioned claims allows capacity to grow without requiring a full data migration, though storage management practice includes verifying expansion support and understanding any related constraints, such as whether the expansion requires a Pod restart to take full effect.
Backup and Recovery Practices
Coordinating Backups With Application-Level Consistency
Because a naive storage-level snapshot taken without application awareness risks capturing an inconsistent state, particularly for database-like stateful workloads, storage management includes coordinating backup timing with application-level consistency mechanisms, such as a brief write-quiescing period, rather than relying purely on storage-layer snapshotting in isolation.
Verifying Restorability of Backups
Periodically testing that backups can actually be restored into a functioning StatefulSet, rather than merely confirming that backup jobs complete successfully, provides genuine confidence in recovery capability, since an unverified backup process risks discovering restoration failures only during an actual disaster recovery scenario.
Handling Storage-Related Failures
Diagnosing Volume Attachment Failures
When a specific ordinal's Pod becomes stuck due to a failure attaching its associated storage, diagnosing whether the cause lies with the underlying storage backend, a node-level attachment limit being reached, or a genuine inconsistency in the claim's binding state determines the appropriate remediation path.
Recovering From Underlying Storage Backend Failures
In the event of an underlying storage backend failure affecting a specific ordinal's volume, storage management includes having a clear recovery procedure, whether restoring from a recent backup or, for applications supporting it, resynchronizing that ordinal's data from its peer replicas.
Decommissioning Storage Responsibly
Confirming Data Is No Longer Needed Before Deletion
Because PersistentVolumeClaims are not automatically deleted alongside a scaled-down or removed StatefulSet by default, storage management includes a deliberate verification step confirming that retained data is genuinely no longer needed before manually deleting the underlying claims and their associated persistent volumes, preventing accidental, irreversible data loss.