From 7e81361b4ec37d7cf85b32b22918018414dfbb3b Mon Sep 17 00:00:00 2001 From: Robert Juzak Date: Thu, 21 Nov 2024 01:05:41 +0100 Subject: [PATCH] close #90 --- charts/nominatim/Chart.yaml | 2 +- charts/nominatim/README.md | 2 +- charts/nominatim/templates/_helpers.tpl | 2 +- charts/nominatim/templates/deployment.yaml | 3 +-- charts/nominatim/templates/initJob.yaml | 27 ++++++++++++++++------ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/charts/nominatim/Chart.yaml b/charts/nominatim/Chart.yaml index 29f66d0..e1714f6 100644 --- a/charts/nominatim/Chart.yaml +++ b/charts/nominatim/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 4.2.3 +version: 4.3.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/nominatim/README.md b/charts/nominatim/README.md index aff294c..cd7dd57 100644 --- a/charts/nominatim/README.md +++ b/charts/nominatim/README.md @@ -535,7 +535,7 @@ kind: Secret metadata: name: my-secret data: - POSTGRESQL_DSN: pgsql:host=release-name-postgresql;port=5432;user=postgres;password=nominatim;dbname=nominatim + POSTGRESQL_DSN: postgresql://user:password@host:port/database ``` ### Ingress diff --git a/charts/nominatim/templates/_helpers.tpl b/charts/nominatim/templates/_helpers.tpl index 93a8edd..59b84ca 100644 --- a/charts/nominatim/templates/_helpers.tpl +++ b/charts/nominatim/templates/_helpers.tpl @@ -87,7 +87,7 @@ Add environment variables to configure database values Create the database URL. */}} {{- define "nominatim.databaseUrl" -}} -pgsql:host={{ include "nominatim.databaseHost" . }};port={{ include "nominatim.databasePort" . }};user={{ include "nominatim.databaseUser" . }};password={{ include "nominatim.databasePassword" . }};dbname={{ include "nominatim.databaseName" . }} +postgresql://{{ include "nominatim.databaseUser" . }}:{{ include "nominatim.databasePassword" . }}@{{ include "nominatim.databaseHost" . }}:{{ include "nominatim.databasePort" . }}/{{ include "nominatim.databaseName" . }} {{- end }} {{- define "nominatim.containerPort" -}} diff --git a/charts/nominatim/templates/deployment.yaml b/charts/nominatim/templates/deployment.yaml index 32f7aba..2b1df1c 100644 --- a/charts/nominatim/templates/deployment.yaml +++ b/charts/nominatim/templates/deployment.yaml @@ -161,8 +161,7 @@ spec: secretKeyRef: name: {{ .Values.externalDatabase.existingSecretDsn }} key: {{ .Values.externalDatabase.existingSecretDsnKey }} - {{- end }} - {{- if not .Values.externalDatabase.existingSecretDsn }} + {{- else }} value: {{ include "nominatim.databaseUrl" . }} {{- end }} {{- if .Values.extraEnvVars }} diff --git a/charts/nominatim/templates/initJob.yaml b/charts/nominatim/templates/initJob.yaml index 7ce6ebc..3a4b291 100644 --- a/charts/nominatim/templates/initJob.yaml +++ b/charts/nominatim/templates/initJob.yaml @@ -27,12 +27,26 @@ spec: {{- end }} initContainers: - name: wait-for-db - image: chainguard/wait-for-it:latest + image: postgres + env: + - name: NOMINATIM_DATABASE_DSN + {{- if .Values.externalDatabase.existingSecretDsn }} + valueFrom: + secretKeyRef: + name: {{ .Values.externalDatabase.existingSecretDsn }} + key: {{ .Values.externalDatabase.existingSecretDsnKey }} + {{- else }} + value: {{ include "nominatim.databaseUrl" . }} + {{- end }} args: - - -h - - {{ include "nominatim.databaseHost" . | quote}} - - -p - - {{ include "nominatim.databasePort" . | quote }} + - /bin/bash + - -c + - | + echo $NOMINATIM_DATABASE_DSN; + until pg_isready -d $NOMINATIM_DATABASE_DSN; do + echo "Waiting for database..." + sleep 2 + done - name: download image: curlimages/curl @@ -113,8 +127,7 @@ spec: secretKeyRef: name: {{ .Values.externalDatabase.existingSecretDsn }} key: {{ .Values.externalDatabase.existingSecretDsnKey }} - {{- end }} - {{- if not .Values.externalDatabase.existingSecretDsn }} + {{- else }} value: {{ include "nominatim.databaseUrl" . }} {{- end }} {{- if .Values.flatnode.enabled }}