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

12/27/2018

In kubenetes what are advantages and disadvantages using single shared pvc for all pod & multiple pvc for each pod.

-- Harsh Manvar
amazon-web-services
docker
kubectl
kubernetes
kubernetes-pvc

1 Answer

12/27/2018

Statefulset with single PV/PVC and Statefulset with multiple PV/PVC has different use cases and should be used according to the application you want to deploy. You can not precede one over another.

Let me explain you with example of databases, if you want to deploy the relational database like postgresql where all the data stored at one place. You need statefulset with single PV/PVC and all replicas to that write to that particular volume only. This is the only way to keep the data consistent in postgresql.

Now lets say you want to deploy a distributed nosql database like cassandra/mongodb, where the data is splitted along the different machines and cluster of database. In such databases, data is replicated over different nodes and in that case statefulsets pods acts as a different node of that database. So, such pods needs different volume to store their data. Hence if you're running cassandra statefulset with 3 pods, those pods must have different PV/PVC attached to them. Each node writes data on its own PV and which ultimately replicated to other nodes.

-- Prafull Ladha
Source: StackOverflow