Running stateful workloads on Kubernetes requires understanding the PersistentVolume subsystem and the StatefulSet workload type. These are more complex than stateless Deployment workloads but necessary for databases, message queues, and other stateful systems.
PersistentVolume provisioning
PersistentVolumes (PVs) are the storage abstraction in Kubernetes. PersistentVolumeClaims (PVCs) are requests for storage that bind to PVs. Dynamic provisioning (StorageClass-based) creates PVs automatically when PVCs are created. In AKS, the default StorageClass provisions Azure Managed Disks. For workloads that need shared storage across pods, Azure Files (SMB/NFS) StorageClasses provide ReadWriteMany access mode (multiple pods can mount the same volume simultaneously).
StatefulSet guarantees
StatefulSets provide three guarantees that Deployments do not: stable pod identity (pods are named pod-0, pod-1 rather than random suffixes), stable network identity (DNS names that persist across pod restarts), and ordered deployment and scaling (pod-0 starts before pod-1 which starts before pod-2). These guarantees are required for clustered databases and message queues that need to know which instance is which and need bootstrapping in order.
Headless services for direct pod access
StatefulSets use headless Services (clusterIP: None) for stable DNS-based pod addressing. A headless Service creates DNS records for each pod individually (pod-0.service.namespace.svc.cluster.local) rather than a single DNS record for the service IP. Applications that need to address specific replicas directly (Cassandra's seed nodes, Kafka's broker IDs) use headless service DNS for peer discovery.
Volume snapshot and backup
Kubernetes volume snapshots (GA in 1.20) provide point-in-time snapshots of PersistentVolumes. On Azure, PV snapshots create Azure Managed Disk snapshots. Velero (VMware) provides Kubernetes-native backup and restore, using volume snapshots for stateful workload backup. Production stateful workloads on Kubernetes need a tested backup and restore procedure, the Kubernetes control plane can be rebuilt, but PV data cannot.