Earlier quoted context omitted.
Kubernetes can’t change any database’s HA or durability features; there’s no magic k8s can apply to make a database that does e.g. asynchronous replication have the properties of one that does synchronous replication. So you’ll never gain any properties your underlying database is incapable of providing. However, if I had to run Postgres as part of something I deployed on k8s AND for some reason couldn’t use my cloud…
> AND for some reason couldn’t use my cloud provider’s built in solution (AWS RDS, Cloud SQL, etc.) Money. > Pay someone else to handle that part Aside from the money (managed Postgres is expensive ), I'd actually like to understand what good, high-availability Postgres solutions look like.
In general, you need some sort of separate strictly serializable store run in an HA configuration to manage the state changes, and whatever is managing the state changes needs to be run in multiple instances across your fault domains as well. Others have mentioned Patroni; I’ve used it before (though with etcd, not k8s) and been quite happy with it. Be aware that (as it cautions you in the README) it’s not a total point and shoot tool, you do need to read through it’s caveats and understand the underlying Postgres replication features.
The documentation is pretty good, if you want to get an idea of what the logic looks like they have a nice state diagram: https://github.com/zalando/patroni/blob/master/docs/ha_loop_...