Rdanzey/helm-fixes-existing-db-secrets (#3033)

Fixes some Helm templating issues when setting up a deployment with an
existing database / signing keys.

- Allows for `.Values.postgresql.enabled: false` as long as
`.Values.global.dendrite_config.database.connection_string` is defined
- Allows for '.Values.signing_key.create: false' if
`.Values.signing_key.existingSecret` is set

Also fixes an error in the template resulting in profiling port not
being set correctly:

```
Error: template: dendrite-meta/charts/dendrite/templates/deployment.yaml:60:35: executing "dendrite-meta/charts/dendrite/templates/deployment.yaml" at <$.Values.global.profiling.port>: nil pointer evaluating interface {}.port
```

### Pull Request Checklist

<!-- Please read
https://matrix-org.github.io/dendrite/development/contributing before
submitting your pull request -->

* [x] I have added Go unit tests or [Complement integration
tests](https://github.com/matrix-org/complement) for this PR _or_ I have
justified why this PR doesn't need tests
  - Helm template fixes, no golang changes
* [x] Pull request includes a [sign off below using a legally
identifiable
name](https://matrix-org.github.io/dendrite/development/contributing#sign-off)
_or_ I have already signed off privately

Signed-off-by: Rhea Danzey <rdanzey@element.io>

---------

Signed-off-by: Rhea Danzey <rdanzey@element.io>
Co-authored-by: Till Faelligen <2353100+S7evinK@users.noreply.github.com>
This commit is contained in:
Rhea Danzey 2023-03-28 01:30:19 -05:00 committed by GitHub
parent f4104b4b5d
commit 28d3e296a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 17 deletions

View file

@ -1,6 +1,6 @@
apiVersion: v2 apiVersion: v2
name: dendrite name: dendrite
version: "0.12.0" version: "0.12.1"
appVersion: "0.12.0" appVersion: "0.12.0"
description: Dendrite Matrix Homeserver description: Dendrite Matrix Homeserver
type: application type: application

View file

@ -1,15 +1,9 @@
{{- define "validate.config" }} {{- define "validate.config" }}
{{- if not .Values.signing_key.create -}} {{- if and (not .Values.signing_key.create) (eq .Values.signing_key.existingSecret "") -}}
{{- fail "You must create a signing key for configuration.signing_key. (see https://github.com/matrix-org/dendrite/blob/master/docs/INSTALL.md#server-key-generation)" -}} {{- fail "You must create a signing key for configuration.signing_key OR specify an existing secret name in .Values.signing_key.existingSecret to mount it. (see https://github.com/matrix-org/dendrite/blob/master/docs/INSTALL.md#server-key-generation)" -}}
{{- end -}} {{- end -}}
{{- if not (or .Values.dendrite_config.global.database.host .Values.postgresql.enabled) -}} {{- if and (not .Values.postgresql.enabled) (eq .Values.dendrite_config.global.database.connection_string "") -}}
{{- fail "Database server must be set." -}} {{- fail "Database connection string must be set." -}}
{{- end -}}
{{- if not (or .Values.dendrite_config.global.database.user .Values.postgresql.enabled) -}}
{{- fail "Database user must be set." -}}
{{- end -}}
{{- if not (or .Values.dendrite_config.global.database.password .Values.postgresql.enabled) -}}
{{- fail "Database password must be set." -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -17,11 +17,7 @@ spec:
labels: labels:
{{- include "dendrite.selectorLabels" . | nindent 8 }} {{- include "dendrite.selectorLabels" . | nindent 8 }}
annotations: annotations:
confighash-global: secret-{{ .Values.global | toYaml | sha256sum | trunc 32 }} confighash: secret-{{ .Values.dendrite_config | toYaml | sha256sum | trunc 32 }}
confighash-clientapi: clientapi-{{ .Values.clientapi | toYaml | sha256sum | trunc 32 }}
confighash-federationapi: federationapi-{{ .Values.federationapi | toYaml | sha256sum | trunc 32 }}
confighash-mediaapi: mediaapi-{{ .Values.mediaapi | toYaml | sha256sum | trunc 32 }}
confighash-syncapi: syncapi-{{ .Values.syncapi | toYaml | sha256sum | trunc 32 }}
spec: spec:
volumes: volumes:
- name: {{ include "dendrite.fullname" . }}-conf-vol - name: {{ include "dendrite.fullname" . }}-conf-vol
@ -57,7 +53,7 @@ spec:
{{- if $.Values.dendrite_config.global.profiling.enabled }} {{- if $.Values.dendrite_config.global.profiling.enabled }}
env: env:
- name: PPROFLISTEN - name: PPROFLISTEN
value: "localhost:{{- $.Values.global.profiling.port -}}" value: "localhost:{{- $.Values.dendrite_config.global.profiling.port -}}"
{{- end }} {{- end }}
resources: resources:
{{- toYaml $.Values.resources | nindent 10 }} {{- toYaml $.Values.resources | nindent 10 }}