Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - Add ssl option to postgres #221

Closed
RegisHubelia opened this issue Oct 16, 2023 · 12 comments
Closed

Feature Request - Add ssl option to postgres #221

RegisHubelia opened this issue Oct 16, 2023 · 12 comments
Assignees

Comments

@RegisHubelia
Copy link

When using custom postgres services (standalone or clusters, but outside of the build-in zammad postgres) - I don't see how to enable ssl to connect to the server. We have a postgres cluster, using bouncers, which requires ssl. We worked around it by connecting directly to the primary instance, but this is far from ideal.

It would be nice to be able to provide either a full url ourselves, or add the ssl options/other options to append to the generated postgres url from the information given in the chart.

@mgruner
Copy link
Collaborator

mgruner commented Oct 17, 2023

Hi @RegisHubelia, this should already be possible by providing your own DATABASE_URL via extraEnv. Can you try if this works for you, please?

@mgruner mgruner closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2023
@mgruner mgruner self-assigned this Oct 17, 2023
@RegisHubelia
Copy link
Author

Will do and revert. Still think this should be an option...

@alexkorotysh
Copy link
Contributor

alexkorotysh commented Oct 23, 2023

@RegisHubelia the solution shoulb be so easy (i'm not sure)
for example,use section

initContainers: []

for downloading your CA cert for DB and put into pod
  - name: download-psql-ca
    image: "curlimages/curl:7.70.0"
    imagePullPolicy: "IfNotPresent"
    volumeMounts:
      - name: psql-ca
        mountPath: /psql-ca
    workingDir: /psql-ca
    command:
      - "/bin/sh"
      - "-ec"
      - |
        curl -Lso /psql/root.pem \
                  https://xxxxxxxxxxxxxxx/CA.pem

DATABASE_URL via extraEnv
set into postgres_dsn option with path for postgresCA

@RegisHubelia
Copy link
Author

Sorry to drop back here and reopen this issue... But setting DATABASE_URL somehow works, but the issue is in the template:

  • name: DATABASE_URL
    value: "postgres://{{ .Values.zammadConfig.postgresql.user }}:$(POSTGRESQL_PASS)@{{ if .Values.zammadConfig.postgresql.enabled }}{{ .Release.Name }}-postgresql{{ else }}{{ .Values.zammadConfig.postgresql.host }}{{ end }}:{{ .Values.zammadConfig.postgresql.port }}/{{ .Values.zammadConfig.postgresql.db }}"**

The DATABASE_URL is set even if we set our own in the extraEnv. so it ends up with something like this in the stateful set for all containers that uses the DATABASE_URL:

        - name: DATABASE_URL
         value: ```generatedvalue```
          valueFrom:
            secretKeyRef:
              key: KEY_IN_SECRET
              name: SECRET_NAME

This gives an error as there is both, the value and the valueFrom keys. The only way I fould around it is to remove the value in the statefulset once it's created/updated. Should be a quick fix tough, simply adding a check if the extraEnv DATABASE_URL exists - if yes use this one, else use the generated one. Happy to open a PR.

@mgruner
Copy link
Collaborator

mgruner commented Mar 5, 2024

Hello @RegisHubelia. You are correct that both values are generated in the template. I tried it and found that the last definition from extraEnv overwrites the first one with a warning, not an error. And the value was the correct one and worked correctly in the deployed application.

@RegisHubelia
Copy link
Author

Strange, this is not my experience... I ended up with both, the "value" key and the "valueFrom". Did you try to set a value, or the valueFrom? If the value key is set, then yes it should overwrite the generated one, but if using a secret, then it's the valueFrom key, which is likely In most scenario, as there is sensitive information in the url therefore using a secret is a better way to go.

@mgruner
Copy link
Collaborator

mgruner commented Mar 6, 2024

Ah, thanks for the explanation. Maybe you can try setting value: ~ as well in your extraEnv? Then you should have only valueFrom to use.

@RegisHubelia
Copy link
Author

The issue is that value cannot be set if valueFrom is. So even with your suggestion, it gives this "create Pod zammad-sd-1 in StatefulSet zammad-sd failed error: Pod "zammad-sd-1" is invalid: [spec.containers[1].env[6].valueFrom: Invalid value: "": may not be specified when value is not empty, "

@mgruner
Copy link
Collaborator

mgruner commented Mar 11, 2024

Overriding with valueFrom like you mentioned does not work. Reopening. Maybe we can solve it together with #251.

@mgruner mgruner reopened this Mar 11, 2024
@mgruner
Copy link
Collaborator

mgruner commented Apr 29, 2024

This has been added recently with 11.0.0. You can now specify/modify zammadConfig.postgresql.options.

@mgruner mgruner closed this as completed Apr 29, 2024
@RegisHubelia
Copy link
Author

Thank you!

@RegisHubelia
Copy link
Author

Worked like a charm. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants