Provide the container registry DB by default for our built Postgresql chart
Summary
We can't guarantee that a fresh install is really a fresh install due to the nature of Backup/Restores. But we can make sure our chart always deploys a separate logical registry database.
Proposal
- DB, User and Extensions provisioning:
- Use
templates/initdb-configmap.yamlto create extra logical DBs, Users and extensions, as I can't find a way to provide DB/User initialization other than theauth:key of the Postgres Bitnamy chart, and it does not seem to support multiple DBs.- We would use
IF NOT EXISTSto make it idempotent. But might not be critical as the Postgresql PV will persist the state file that indicates that we have already initialized it. - Delver further: https://github.com/bitnami/containers/blob/main/bitnami/postgresql/17/debian-12/rootfs/opt/bitnami/scripts/postgresql/setup.sh
- All of this is only relevant if
postgresql.install: true.
- We would use
- The global.psql.{main | ci} seem very much coupled to GitLab Rails implementation and configuration. I'm a bit reluctant to extend that. I believe the best approach is to expose
global.registry.databaseto thetemplates/initdb-configmap.yamlto be able to initialize DB/User/Extensions. - We can merge the global into the local registry.database stuff. There's no real reason to deprecate the current configs.
- Operator V2 relies on external DB anyway.
- Use
- Migrations and SKIP_POST_DEPLOYMENT_MIGRATIONS
- Already supported
- We won't support automated post deploy migrations.
Implementation details
- Provide new
global.registry.database.{user, name}keys to the chart. - Default there values to whatever the container registry team prefers.
- Within the registry chart templates functions, if
registry.database.{user, name}is set, give preference to that, because it means that users have already configured that for an external instance. If it's not set, take the ones from global. - On the
templates/initdb-configmap.yamlfile, create a newdata.init_registry.shkey, which executespsqlcommands to create the registry user and database, taking their names from the new global keys. - If certain DB extensions are required, also create them within the same script.
Relevant links
Edited by João Alexandre Cunha