How to run multiple insurance of MySQL in kubernetes

4/14/2020

we are trying to setup mysql server with below configurations.

3 mysql pods with sharing same persistence volume and data should be available across all pods and any pods can execute read and write requests and a load balancer to route the traffic to different pods based on load. Hope kubernetes service will take care to route the traffic. I tried master and salve method here master is only suitable for write and slave for read. Can anyone explain which methods are available to full fill my requirements.

-- Narasimhamurthy K
docker
kubernetes
mysql

1 Answer

4/15/2020

Welcome to Stack Overflow!

For allow write in all pods os mysql you'll need to setup mysql in multi-master topology, master-slave topology only will permit write on master pod.

Here are some reference for mysql multi-master topology:

http://dbadiaries.com/how-to-setup-mysql-master-master-replication

From this pods you can use persistent volumes to shared data between the pods

Here you have a example of how setup mysql in master-slave topology, you'll need to adjust for your needs.

For handle the connection, you need to create a service for your pods, the serviceType will depends of how you'll expose your service.

-- KoopaKiller
Source: StackOverflow