6

I have a MySQL database pod with 3 replicas.
Now I'm making some changes in one pod(pod data,not pod configuration), say I'm adding a table.
How will the change reflect on the other replicas of the pod?

I'm using kubernetes v1.13 with 3 worker nodes.

AATHITH RAJENDRAN
  • 4,689
  • 8
  • 34
  • 58

5 Answers5

3

PODs do not sync. Think of them as independend processes.

If you want a clustered MySQL installation, the Kubernetes docs describe how to do this by using a StatefulSet: https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/#deploy-mysql

In essence you have to configure master/slave instances of MySQL yourself.

Markus Dresch
  • 5,290
  • 3
  • 20
  • 40
1

Pods are independent from each other, if you modify one pod the others will not be affected

S. Schenkel
  • 181
  • 9
  • 1
    I'm not changing the pod specs, my question is how the change in one replica of the pod(data inside pods) reflects on other replicas @schenkel – AATHITH RAJENDRAN Mar 18 '19 at 03:54
  • 1
    yes I was referring to any type of changes (data inside, specs etc...) like @VKR said you should use StatefulSet, his answer is good – S. Schenkel Mar 18 '19 at 09:40
1

As per your configuration - changes applied in one pod wont be reflected on all others. These are isolated resources. There is a good practice to deploy such things using PersistentVolumeClaims and StatefulSets.

You can always find explanation with examples and best practices in Run a Replicated Stateful Application documentation.

Vit
  • 7,740
  • 15
  • 40
0

If you have three mysql server pods, then you have 3 independent databases. Even though you created them from the same Deployment. So, depending on what you do, you might end up with bunch of databases in the cluster.

I would create 1 mysql pod, with persistence, so if one pod dies, the next one would take if from where the other one left. Would not lose data.

If what you want is high availability, or failover replica, you would need to manage it on your own.

Generally speaking, K8s should not be used for storage purposes.

suren
  • 7,817
  • 1
  • 30
  • 51
-1

You are good to have common storage among those 3 pods (PVC) and also consider STS when running databases on k8s.

hariK
  • 2,722
  • 13
  • 18