How pod replicas sync with each other - Kubernetes?
Asked Answered
T

5

7

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.

Tangency answered 12/3, 2019 at 4:22 Comment(3)
(This explanation is just an example of what I want to know)Tangency
you make changes in nodes/services, not pods, pods are initiated when you run these nodes and services. So any change in the node/service will be reflected in all the 4 pods.Announcement
can you elobrate, please?@MukarramAliTangency
H
4

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.

Hudgins answered 12/3, 2019 at 12:52 Comment(0)
C
2

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.

Cella answered 12/3, 2019 at 11:22 Comment(0)
S
1

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

Selfacting answered 12/3, 2019 at 10:54 Comment(2)
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 @schenkelTangency
yes I was referring to any type of changes (data inside, specs etc...) like @VKR said you should use StatefulSet, his answer is goodSelfacting
M
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.

Moir answered 12/3, 2019 at 11:28 Comment(0)
C
-1

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

Chinch answered 12/3, 2019 at 11:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.