I am running a statefulset in my cluster and am trying to assign each of the replicas (3 in total) to assign their own PVC. Unfortunately, I can only provide 1 name as claimName. How do I make sure each starting pod grabs it's own pvc? The pods I am using are currently called test and so are the pvcs. So when I start up the containers I have a pod called test-0, test-1 and test-2. My PCVs are called claim-0, claim-1 and claim-2. What options do I have to tell pod test-0 to grab the claim-0 pvc, pod-1 to grab claim-1, etc? Thanks for your input.
If each pod in your StatefulSet requires its down PV, you should be creating your StatefulSet using a
volumeClaimTemplates
section, as shown in the documentation:So if you create a StatefulSet like this:
Then you'll end up with three pods:
And three PVCs:
Each one linked to a specific pod.