<p>I have deploy kubernetes cluster with stateful pod for mysql. for each pod i have different pvc.</p>

<p>for example : if 3 pod thn 3 5GB EBS PVC </p>

<p>SO Which way is better using one PVC for all pods or use different pvc for each pod.</p>

Harsh Manvar
<p>StatefulSet must use volumeClaimTemplates if you want to have dedicated storage for each pod of a set. Based on that template PersistentVolumeClaim for each pod is created and configured the volume to be bound to that claim. The generated PersistentVolumeClaims names consists of volumeClaimTemplate name + pod-name + ordinal number.
So if you add volumeClaimTemplate part to your StatefulSet YAML(and delete specific persistentVolumeClaim references), smth like that: </p>

<pre><code>volumeClaimTemplates:
  - metadata:
      name: mysql-data    
    spec:
      resources:
        requests:
          storage: 10Gi
      accessModes:
      - ReadWriteOnce
</code></pre>

<p>Then go and create your StatefulSet and after to examine one of its pods (kubectl get pods pod-name-0 yaml) you’ll see smth like that(volumes part of the output):</p>

<pre><code>volumes:
- name: mysql-data
  persistentVolumeClaim:
    claimName: mysql-data-pod-name-0.  | dynamically created claim based on the template 
</code></pre>

<p>So by using volumeClaimTemplates you don’t need to create a separate PVCs yourself and then in each separate StatefulSet  reference that PVC to be mounted in your container at a specific mountPath(remember that each pod of a set must reference a different PVC, 1PVC-1PV) :
Part of “containers” definition of your Statefulset YAML:</p>

<pre><code>volumeMounts:
        - name: mysql-data   || references your PVC by -name(not PVC name itself) 
          mountPath: /var/lib/mysql
</code></pre>

<p>So to aim for each pod of the set to have dedicated storage and not use volumeClaimTemplates is leading to a lot of problems and over complications to manage and scale it.</p>
