robjuz / helm-charts

https://robjuz.github.io/helm-charts/index.yaml
34 stars 30 forks source link

[nominatim] wait-for-db doesn't support an external database through a k8s secret #90

Open Longwelwind opened 2 months ago

Longwelwind commented 2 months ago

Hello,

Here's my values.yml:

externalDatabase:
  existingSecretDsn: external-database
  existingSecretDsnKey: POSTGRESQL_DSN
initJob:
  enabled: true
postgresql:
  enabled: false

The init job fails because of the wait-for-db init container:

wait-for-it: waiting 15 seconds for localhost:5432
wait-for-it: timeout occurred after waiting 15 seconds for localhost:5432

I may be mistaken, but I think it may be because the configuration of the wait-for-it init container doesn't take into account the possibility that the external database credentials were defined in an external secret, as defined here: https://github.com/robjuz/helm-charts/blob/master/charts/nominatim/templates/_helpers.tpl#L49

If it was defined in a external secret, this secret should be mounted inside the init container and should be used as part of the command.

Thanks in advance (if you find the time to fix it) and thanks a lot for the helm chart! 🙂

JakobHtz commented 1 month ago

Hi,

I had a similar issue, where i ran into the wait-for-it timeout everytime. You can increase the timeout, but you would need to modify the templates for that. This worked for me.

That would be adding this to the args (there: https://github.com/robjuz/helm-charts/blob/master/charts/nominatim/templates/initJob.yaml#L31)

            - t
            - "60"

It would be good to be able to set that from the values yaml, I think 15sec is kind of short for an database-init timeout.

I dont know if wait-for-it needs to know more than host an port https://images.chainguard.dev/directory/image/wait-for-it/overview

JakobHtz commented 1 month ago

I looked into it a bit more. You are right. The helper function does not get the host and port from the secret, but you can set them in the values.yaml Could be worth a try as a workaround

externalDatabase:
  existingSecretDsn: external-database
  existingSecretDsnKey: POSTGRESQL_DSN
  host: <Your DB Host>
  port: <Your DB Port>
initJob:
  enabled: true
postgresql:
  enabled: false