How pod replicas sync with each other - Kubernetes?

3/12/2019

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
kubernetes
kubernetes-pod
kubernetes-service

5 Answers

3/12/2019

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
Source: StackOverflow

3/12/2019

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
Source: StackOverflow

3/12/2019

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

-- S. Schenkel
Source: StackOverflow

3/12/2019

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.

-- VKR
Source: StackOverflow

3/12/2019

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

-- hariK
Source: StackOverflow