Take this case https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/ for example (suppose we need write to the database). Is the data synced among each mysql isntance? If not, if there is any way to do it?
Is the data synced among each mysql isntance?
Disclaimer: although question title is centered around mongodb this answer is directed to your actual question (given example StatefulSet and mysql).
Yes. The StatefulSet in the link you provided is keeping one master pod and two read-only pods in sync.
Notes:
As noted in the documentation:
this is not a production configuration.
In particular, MySQL settings remain on insecure defaults
to keep the focus on general patterns for running stateful applications in Kubernetes.