Database on kubernetes

One simple question. I would like to containerize a postgresql RDBMS and use a volume for persistent storage.
Say it is time to scale because the traffic is rising. Since postgresql does not support multi master how this is going to work? Because one request might go to x pod and another to y pod.

Regards
Klention

Scaling horizontally isn’t really an option for Postgres, regardless of Kubernetes, at least not that I’m aware of.
Do you currently use Postgres at the VM level? If so how do you scale there?

Kind regards,
Stephen

Hi,

Do you currently use Postgres at the VM level? If so how do you scale there?
We don’t scale.
Currently we have postgresql on a master slave cluster on physical servers (high end specs). But since all the traffic is going to master node, the slaves are just sitting there doing nothing but replicating.
And since all of our services (except database) run on kubernetes we thought if it might be a way to move the database also.

Regards,
Klention

You can send request directly to the one pod using its name (statefulset’s pods have well-defined names) - StatefulSets | Kubernetes

Not to reinventing the wheel you can check projects which manage DBs on K8s: GitHub - zalando/postgres-operator: Postgres operator creates and manages PostgreSQL clusters running in Kubernetes and GitHub - CrunchyData/postgres-operator: Production PostgreSQL for Kubernetes, from high availability Postgres clusters to full-scale database-as-a-service.

Regards,
Tomasz Prus

So you’re going to have a similar setup using the links provided by @tomasz.prus, master node receiving data writes and data replicated to slave nodes.
It does look like you can implement read only slaves which might relieve some of the workload from the master:

But you are still restricted by the master slave type architecture.

Kind regards,
Stephen

Thank you all for your time and help.
I will be looking those links.

Regards,
Klention