From aa65e3b613138124d081c8a7ec9f1a5d9b68b6a1 Mon Sep 17 00:00:00 2001 From: Omar Qunsul Date: Wed, 21 Jun 2023 13:32:13 +0300 Subject: [PATCH] Supporting Decomposed Database in Helm Charts Upgrading postgresql subchart and supporting decomposed database setup Changelog: feature --- examples/values-minikube.yaml | 5 +++++ requirements.yaml | 5 +++++ templates/_helpers.tpl | 2 +- templates/initdb-configmap.yaml | 2 +- values.yaml | 38 +++++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) diff --git a/examples/values-minikube.yaml b/examples/values-minikube.yaml index 4e0d3c9c29..81073c8daf 100644 --- a/examples/values-minikube.yaml +++ b/examples/values-minikube.yaml @@ -15,6 +15,11 @@ global: # Configure the clone link in the UI to include the high-numbered NodePort # value from below (`gitlab.gitlab-shell.service.nodePort`) port: 32022 + #psql: + #ci: + #database: gitlabhq_production_ci + #serviceName: gitlab-postgresql-ci + # Don't use certmanager, we'll self-sign certmanager: install: false diff --git a/requirements.yaml b/requirements.yaml index 7192f893b9..6a586a7cff 100644 --- a/requirements.yaml +++ b/requirements.yaml @@ -20,6 +20,11 @@ dependencies: version: 12.5.2 repository: https://charts.bitnami.com/bitnami condition: postgresql.install +- name: postgresql + version: 12.5.2 + repository: https://charts.bitnami.com/bitnami + alias: postgresql-ci + condition: postgresql.install - name: gitlab-runner version: 0.52.0 repository: https://charts.gitlab.io/ diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index e912bf6b0e..68c2521d10 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -249,7 +249,7 @@ Uses `postgresql-password` to match upstream postgresql chart when not using an {{- define "gitlab.psql.password.key" -}} {{- $local := pluck "psql" $.Values | first -}} {{- $localPass := pluck "password" $local | first -}} -{{- default "postgresql-password" (pluck "key" $localPass $.Values.global.psql.password | first ) | quote -}} +{{- default "password" (pluck "key" $localPass $.Values.global.psql.password | first ) | quote -}} {{- end -}} {{/* diff --git a/templates/initdb-configmap.yaml b/templates/initdb-configmap.yaml index fa65d5d49a..cd641064b6 100644 --- a/templates/initdb-configmap.yaml +++ b/templates/initdb-configmap.yaml @@ -16,6 +16,6 @@ data: fi enable_extensions.sh: | [[ -n "${POSTGRES_POSTGRES_PASSWORD_FILE:-}" ]] && POSTGRES_POSTGRES_PASSWORD=$(cat ${POSTGRES_POSTGRES_PASSWORD_FILE}) - PGPASSWORD=${POSTGRES_POSTGRES_PASSWORD} psql -d {{ template "gitlab.psql.database" .}} -U postgres -c 'CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE EXTENSION IF NOT EXISTS btree_gist;' + PGPASSWORD=${POSTGRES_POSTGRES_PASSWORD} psql -d {{ template "gitlab.psql.database" .}} -U postgres -c 'ALTER USER {{ template "gitlab.psql.username" .}} SUPERUSER; CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE EXTENSION IF NOT EXISTS btree_gist;' # Leave this here - This line denotes end of block to the parser. {{- end -}} diff --git a/values.yaml b/values.yaml index f8951abea7..8043162dc2 100644 --- a/values.yaml +++ b/values.yaml @@ -1115,6 +1115,44 @@ postgresql: ## Optionally define additional custom metrics ## ref: https://github.com/wrouesnel/postgres_exporter#adding-new-metrics-via-a-config-file +postgresql-ci: + nameOverride: postgresql-ci + install: true + auth: + database: gitlabhq_production_ci + ## These need to be set, for the sake of bitnami/postgresql upgrade patterns. + ## They are overridden by use of `existingSecret` + password: bogus-satisfy-upgrade + postgresPassword: bogus-satisfy-upgrade + ## + usePasswordFiles: false + existingSecret: '{{ include "gitlab.psql.password.secret" . }}' + secretKeys: + adminPasswordKey: postgresql-postgres-password + userPasswordKey: '{{ include "gitlab.psql.password.key" $ }}' + image: + tag: 14.8.0 + primary: + initdb: + scriptsConfigMap: '{{ include "gitlab.psql.initdbscripts" $}}' + extraVolumeMounts: + - name: custom-init-scripts + mountPath: /docker-entrypoint-preinitdb.d/init_revision.sh + subPath: init_revision.sh + podAnnotations: + postgresql.gitlab/init-revision: "1" + metrics: + enabled: true + service: + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9187" + gitlab.com/prometheus_scrape: "true" + gitlab.com/prometheus_port: "9187" + + ## Optionally define additional custom metrics + ## ref: https://github.com/wrouesnel/postgres_exporter#adding-new-metrics-via-a-config-file + ## Installation & configuration charts/registry ## https://docs.gitlab.com/charts/architecture/decisions#registry ## https://docs.gitlab.com/charts/charts/registry/ -- GitLab