Score:0

Kubernetes InnoDBCluster: all pods should share one PersistentVolumeClaim?

ec flag

Kubernetes InnoDBCluster: all pods should share one PersistentVolumeClaim?

Following: https://dev.mysql.com/doc/mysql-operator/en/mysql-operator-innodbcluster-simple-kubectl.html

kubectl create namespace mysql-cluster-test
kubectl create secret generic mypwds \
  --from-literal=rootUser=root \
  --from-literal=rootHost=% \
  --from-literal=rootPassword=123456 -n mysql-cluster-test
kubectl apply -f mycluster.yaml -n mysql-cluster-test

Kubectl get pods -n mysql-cluster-test

NAME                                READY   STATUS    RESTARTS   AGE
mycluster-0                         2/2     Running   0          12m
mycluster-1                         2/2     Running   0          12m
mycluster-2                         2/2     Running   0          12m
mycluster-router-5d87fbd754-zhsrh   1/1     Running   0          10m

kubectl get pvc -n mysql-cluster-test

NAME                  STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
datadir-mycluster-0   Bound    pvc-b3bf5f24-99d0-4497-bd34-fd91eb4adc6c   2Gi        RWO            hostpath       8m9s
datadir-mycluster-1   Bound    pvc-1c042c50-bc3f-43f8-8e16-094042495e6d   2Gi        RWO            hostpath       8m9s
datadir-mycluster-2   Bound    pvc-85fbf9f9-d975-4899-a292-d247644cb2d2   2Gi        RWO            hostpath       8m9s

There are 3 mysql PODs, each of which has its own PVC and bound to different Volumes. Mysql data needs to be stored in one volume. Should all the PODs share one PVC?

pt flag
If you are creating a mysql cluster, that typically means that each instance has its own local storage which is kept in sync via a replication protocol.
eastwater avatar
ec flag
Will local storage be deleted when a pod is deleted? replication will cause performance overhead in case of many nodes. Is there a way to configure a central shared volume? pros and cons? thanks.
Score:0
pt flag

There are 3 mysql PODs, each of which has its own PVC and bound to different Volumes. Mysql data needs to be stored in one volume. Should all the PODs share one PVC?

MySQL (and other SQL databases) aren't built to operate with shared storage. If you want more than a single instance, then each instance needs its own dedicated storage. In a cluster configuration, each instance uses some form of replication to keep their local copy up-to-date with other members of the cluster.

This is generally what you want -- even if you could use a single shared PV, losing the PV would mean you would lose all your data. By using replication, another instance in the cluster can take over the primary role (or can continue providing access if you have multiple read/write replicas).

You could use a single volume and then use a separate directory for each instance, but as noted previously that makes your storage a single point of failure (and also a single point of i/o contention).

Will local storage be deleted when a pod is deleted?

If you are using ephemeral storage for the database, then yes. If you put the database stored on a (non-shared) PV, then no. Using a PV for storage is usually the best plan; in the event of a Pod restart (such as when upgrading versions) that minimizes the amount of data that needs to be transferred to resync the replica.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.