Kubernetes multiple pvc with statefulset for each pod vs single pvc for all pods?

Harsh Manvar

I have deploy kubernetes cluster with stateful pod for mysql. for each pod i have different pvc.

for example : if 3 pod thn 3 5GB EBS PVC

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

Alexz

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:

volumeClaimTemplates:
  - metadata:
      name: mysql-data    
    spec:
      resources:
        requests:
          storage: 10Gi
      accessModes:
      - ReadWriteOnce

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):

volumes:
- name: mysql-data
  persistentVolumeClaim:
    claimName: mysql-data-pod-name-0.  | dynamically created claim based on the template 

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:

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

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to set pvc with statefulset in kubernetes?

What advantage and disadvantages using shared volume between pod vs. each pod having own pvc volume(in case of statefulset)?

why the postgersql kubernetes statefulset did not claim the PVC

Is a Kubernetes StatefulSet the right answer if all we need is a consistent identifier for each Pod in a group of identical Pods?

Multiple Kubernetes pods sharing the same host-path/pvc will duplicate output

Creating multiple PV and PVC in same kubernetes namespace

Kubernetes Helm PVC

kubernetes expanding pvc for cluster

Kubernetes PVC data persistent

Kubernetes PVC with ReadWriteMany on AWS

Kubernetes PVC volume mount

Kubernetes: multiple pods in a node when each pod exposes a port

is it possible to change the kuberentes statefulset PVC binding

Timeout mounting PVC volume to pod

could not delete PVC in kubernetes foregroundDeletion

Kubernetes automatically adds the storageClassName to PVC

Kubernetes - PVC not binding the NFS PV

Monitoring Kubernetes PVC disk usage

Unable to mount PVC created by OpenEBS on pods on Kubernetes bare-metal deployment

Why cant I mount the same PVC twice with different subpaths to single pod?

Pod access PVC subdirectory that already existed

How to use a storage class for StateFulSet? Do I have to create a PVC?

Expand size PVC of statefulset on k8s 1.9

Multiple Pods for multiple clients on a single Kubernetes Instance

how pvc decide which pv to bound in kubernetes

Kubernetes - How do I mention hostPath in PVC?

Kubernetes: Can't delete PersistentVolumeClaim (pvc)

kubernetes change PVC from ReadWriteOnce to ReadWriteMany

Kubernetes PVC restored from VolumeSnapshot is empty