score-compose icon indicating copy to clipboard operation
score-compose copied to clipboard

[feature request] add `postgres-instance` provisioner based on postgres provisioner

Open astromechza opened this issue 1 year ago • 5 comments

In some cases, the workload expects to receive an admin user credentials for a database host and the app will create its own database within the instance. We usually call this an -instance resource, and it has the same outputs except that it provides the root user and password and without the database/name output.

This should be based on the existing type=postgres default provisioner.

astromechza avatar Dec 06 '24 12:12 astromechza

Good example with Backstage indeed, thanks for capturing this!

mathieu-benoit avatar Dec 06 '24 12:12 mathieu-benoit

@astromechza, as a side note here, in the score-k8s's default provisioner, the implementation is different. I'm wondering in which direction we should go though:

  1. Like current score-k8s (i.e. allowing the postgres to create databases)?
  2. Or like recommended in this current issue by adding a new postgres-instance but them have this consistent in score-k8s for consistency?

Also, quid of mysql, mssql, etc. where we should go with this approach too for consistency?

mathieu-benoit avatar Dec 09 '24 20:12 mathieu-benoit

@mathieu-benoit For consistency I think we should make the score-k8s one more advanced and run as a non super user. And then the postgres-instance one can produce a super user and no explicit database field.

astromechza avatar Jan 15 '25 12:01 astromechza

Bonjour @mathieu-benoit @astromechza Can I contribute to this issue ?

rabelmervin avatar Feb 18 '25 02:02 rabelmervin

@rabelmervin sure. See the existing postgres provisioner here: https://github.com/score-spec/score-compose/blob/140cab02dcadb08bd0b8239cc00482d5080b35a9/internal/command/default.provisioners.yaml#L103. I suggest you copy that one, remove any database specific stuff from it and store its state in the local resource state rather than shared state.

I know in my initial issue description I mentioned that it should share state with the Postgres database provisioner, however, I think that might be too complex to be worth it right now — and quite hard to get right with just the existing template language.

astromechza avatar Feb 18 '25 15:02 astromechza

Done in there https://github.com/score-spec/score-compose/pull/284, was also added in https://github.com/score-spec/score-k8s/pull/179. And these unblocked the implementation of https://medium.com/@mabenoit/deploy-backstage-with-score-45bb2d7c2d90.

mathieu-benoit avatar Jun 10 '25 18:06 mathieu-benoit