Can I rely on volumeClaimTemplates naming convention? Can I rely on volumeClaimTemplates naming convention? kubernetes kubernetes

Can I rely on volumeClaimTemplates naming convention?


Based on the statefulset API reference

volumeClaimTemplates is a list of claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod. Every claim in this list must have at least one matching (by name) volumeMount in one container in the template. A claim in this list takes precedence over any volumes in the template, with the same name.

So I guess you can rely on it.

Moreover, you can define a storage class to leverage dynamic provisioning of persistent volumes, so you won't have to create them manually.

  volumeClaimTemplates:  - metadata:      name: www    spec:      accessModes: [ "ReadWriteOnce" ]      storageClassName: my-storage-class      resources:        requests:          storage: 1Gi

Please refer to Dynamic Provisioning and Storage Classes in Kubernetes for more details.