Allow Creation of Multiple Databases #497
Replies: 12 comments 8 replies
-
Not supporting multiple databases was a design decision we took to push a "1 database per cluster" approach. So I don't think we are going to support it in the future. |
Beta Was this translation helpful? Give feedback.
-
I confirm though what Philippe says that for the moment our priority was microservice databases. So for example, in your case @MarkCupitt you can probably get better results by having each database being mapped in a separate Postgres cluster. There's a FAQ item that explains the reasoning behind this approach: https://github.com/cloudnative-pg/cloudnative-pg/blob/main/docs/src/faq.md In any case, there is an open item in the aspirational roadmap called "Declarative Database Management" - see https://github.com/orgs/cloudnative-pg/projects/1. This is also related to the "Declarative Role Management" item. |
Beta Was this translation helpful? Give feedback.
-
Thanks @phisco and @gbartolini, really appreciate your time to comment, We actually read and reviewed your Blog, which makes some excellent points,. our issue is that we are likely to have well over 20 databases when we hit production, (our use case is in the FinTech area) whilst we totally agree with the one database per micro-service approach, the pod count will simply drown us if we adopt one database per db cluster .. We will be watching closely as we really like the approach you have adopted .. and when it makes sense we will split back out that way. Im thinking we may group the lighter use databases in one cluster and split out the heavy use ones in the final deployment approach |
Beta Was this translation helpful? Give feedback.
-
I'm also interested in this behaviour. I don't think multiple databases per cluster breaks the single database per microservice concept (which I consider an almost un-breakable requirement), I do agree that single database per cluster is architecturally superior but a pragmatic approach should be taken. Adding init support for multiple databases is better than leaving database creation to imperative operations, but I think declarative database (and role) management is a strong requirement. IMHO it makes more sense for this operator to support database/role management than requiring the addition of something like CrossPlane. |
Beta Was this translation helpful? Give feedback.
-
I agree with @stevehipwell, not supporting creating multiple databases just leaves it up to having people use external tools like terraform, ansible or bash glue or whatever to have that support where having it built into cnpg would be only a few extra lines of config. Not everyone can follow the "1 database per cluster" method so easily. |
Beta Was this translation helpful? Give feedback.
-
Turning this into a discussion, so we can make a decision after discussing and iterate into a good idea. |
Beta Was this translation helpful? Give feedback.
-
An approach I took in my home setup for multiple applications to use the same Postgres instance is to use https://github.com/movetokube/postgres-operator, that might be useful to some here. I do agree that having something like that built into CNPG would be quite nice. |
Beta Was this translation helpful? Give feedback.
-
I know it's nothing more than a hack and you'll not have your passwords reconciled, but until we the "Declarative Database/Role Management" is done you could do something like this:
This will result in:
Will this help? |
Beta Was this translation helpful? Give feedback.
-
One MariaDB Operator has such a feature inbuilt which uses multiple CRDs to achieve user/database management. Hope that this will help pave the way for the PostgreSQL operator See This helps to decouple the cluster management and the database management so that the devops and the dev team can manage them separately |
Beta Was this translation helpful? Give feedback.
-
I was having the same thoughts @lwj5 - Allow declarative management of Databases #3109 |
Beta Was this translation helpful? Give feedback.
-
having multiple database with each, has minimum 2 replica, has its own pooler, has its own metric collector, I think for my current usage its overkill, although my biggest concern right now is the PVC usage that directly increase Longhorn manager memory usage linearly (with each cnpg pvc created), I think I'd rather have single clustered postgresql, rather than many clustered postgresql Also in the end, I still can create database manually, wait I still can create database manually and it wont be synced or purged by CNPG right ?, or am I stuck withh having single DB if I want to use CNPG ? |
Beta Was this translation helpful? Give feedback.
-
I create the extra db in |
Beta Was this translation helpful? Give feedback.
-
The current bootstrap: initdb allows for the creation of a single database with its associated user/owner, for example:
We have a K8's application that uses several databases and we would like to create them all at once in this manner if at all possible
Beta Was this translation helpful? Give feedback.
All reactions