Kubernetes replicasets and database

2/4/2020

I have a simple question on replicaSets or just replicas. When having 3 Replicas as such:

a pod containing 2 containers 1 x django application and a 1x Postgresql database(linked to a volume)

How is the replication handled in terms of information? I mean how are the database synced to have the same information at all time? I would like to have a better grasp of the concept.

Thank you.

-- Miguel Rosales
kubernetes
kubernetes-pod

1 Answer

2/4/2020

You wouldn't usually use ReplicaSets directly anymore, but assuming you mean in the context of a Deployment: each pod will be identical based on the template you provide. This means they will each get the same volume definition. What that does is mostly up to your choice of plugins and whatnot. There are volume providers that support multiple access (called ReadWriteMany mode). That said, Postgres does not support multiple processes using the same underlying files so that would not work in your particular case. What you would use instead is a StatefulSet, which lets you separately define volume templates so each pod gets a unique persistent volume.

-- coderanger
Source: StackOverflow