volumeClaimTemplates

volumeClaimTemplates and Per-Pod Storage

A StatefulSet's volumeClaimTemplates stamps out one PersistentVolumeClaim per Pod, named <template>-<set>-<N>, so postgres-0 always gets data-postgres-0. The claim is created before its Pod, bound once, and reattached whenever that Pod is recreated, on whatever node the volume allows.

By default, deleting or scaling down a StatefulSet leaves the claims, and their data, in place: scaling back up reattaches them. persistentVolumeClaimRetentionPolicy (stable since 1.32) changes that with whenDeleted and whenScaled, each Retain (the default) or Delete. For a database, keep the default and delete claims by hand when you mean it; the Retain class from Local Storage then keeps even the volume.