0
votes

I was going through in depth of K8s volumes and one of the concept messed me up. It would be great if someone could explain me this. These are the modes in K8s volumes.

ReadWriteOnce -- the volume can be mounted as read-write by a single node

ReadOnlyMany -- the volume can be mounted read-only by many nodes

ReadWriteMany -- the volume can be mounted as read-write by many nodes

  1. What if I run two mysql pods on same node and the mode is ReadWriteOnce ? How my both pods will write?

  2. What if I run two mysql pods on two different nodes and the mode is ReadWriteOnce ? How my both pods will write?

  3. What if I run two mysql pods on same node and the mode is ReadWriteMany ? How my both pods will write?

  4. What if I run two mysql pods on two different nodes and the mode is ReadWriteMany ? How my both pods will write?

All have same pod replica.

2

2 Answers

2
votes

What if I run two mysql pods on same node and the node is ReadWriteOnce ? How my both pods will write?

If you run two DBMS systems (e.g. MySQL or PostgreSQL) in Pods, they are both independent and they should have two independent PersistentVolumeClaims. Only run single-node DBMS for test purposes. For production consider a distributed database that replicates the data.

What if I run two mysql pods on two different node and the node is ReadWriteOnce ? How my both pods will write?

As I recommended above, the two should be independent (unless you use a distributed database like cockroachDB) so running on different nodes is perfectly fine.

What if I run two mysql pods on same different node and the node is ReadWriteMany ? How my both pods will write?

MySQL is a single-node DBMS system, it should not share volumes/files with other instances unless you run a clustered system.

What if I run two mysql pods on two different node and the node is ReadWriteMany ? How my both pods will write?

Same as above, single-node system should not share volumes/files.

0
votes

Just explored and implemented and got few information and thanks to @jonas

What if I run two mysql pods on same node and the mode is ReadWriteOnce ? How my both pods will write?

  • We cannot schedule two pods of mysql on same node, it will result in crashloopbackoff.

What if I run two mysql pods on two different nodes and the mode is ReadWriteOnce ? How my both pods will write?

  • Since the mode is ReadWriteOnce, the data will be written by only one pod in one node based on order.

What if I run two mysql pods on same node and the mode is ReadWriteMany ? How my both pods will write?

  • Was not able to schedule two pods on single node. Resulted in crashloopbackoff

What if I run two mysql pods on two different nodes and the mode is ReadWriteMany ? How my both pods will write?