AATHITH RAJENDRAN
AATHITH RAJENDRAN

Reputation: 5376

How pod replicas sync with each other - Kubernetes?

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.

Upvotes: 7

Views: 9030

Answers (5)

Markus Dresch
Markus Dresch

Reputation: 5574

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.

Upvotes: 4

suren
suren

Reputation: 8786

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.

Upvotes: 0

Vit
Vit

Reputation: 8431

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.

Upvotes: 2

hariK
hariK

Reputation: 3059

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

Upvotes: -1

S. Schenkel
S. Schenkel

Reputation: 191

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

Upvotes: 1

Related Questions