Skip to content

Commit

Permalink
Set DB name and host via external secret (#366)
Browse files Browse the repository at this point in the history
* Set DB name and host via external secret

Signed-off-by: Jack Henschel <jackdev@mailbox.org>

* Update charts/nextcloud/templates/_helpers.tpl - add missing {{- end }}

Signed-off-by: JesseBot <jessebot@linux.com>

---------

Signed-off-by: Jack Henschel <jackdev@mailbox.org>
Signed-off-by: JesseBot <jessebot@linux.com>
Co-authored-by: JesseBot <jessebot@linux.com>
  • Loading branch information
jacksgt and jessebot committed Jul 12, 2023
1 parent 14423bf commit 0c4de8f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/nextcloud/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: nextcloud
version: 3.5.18
version: 3.5.19
appVersion: 27.0.0
description: A file sharing server that puts the control and security of your own data back into your hands.
keywords:
Expand Down
2 changes: 2 additions & 0 deletions charts/nextcloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ If you choose to use one of the prepackaged Bitnami helm charts, you must config
| `externalDatabase.existingSecret.secretName` | Name of the existing secret | `nil` |
| `externalDatabase.existingSecret.usernameKey` | Name of the key that contains the username | `nil` |
| `externalDatabase.existingSecret.passwordKey` | Name of the key that contains the password | `nil` |
| `externalDatabase.existingSecret.hostKey` | Name of the key that contains the database hostname or IP address | `nil` |
| `externalDatabase.existingSecret.databaseKey` | Name of the key that contains the database name | `nil` |
| `mariadb.enabled` | Whether to use the MariaDB chart | `false` |
| `mariadb.auth.database` | Database name to create | `nextcloud` |
| `mariadb.auth.username` | Database user to create | `nextcloud` |
Expand Down
28 changes: 28 additions & 0 deletions charts/nextcloud/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,23 @@ Create environment variables used to configure the nextcloud container as well a
{{- else }}
{{- if eq .Values.externalDatabase.type "postgresql" }}
- name: POSTGRES_HOST
{{- if .Values.externalDatabase.existingSecret.hostKey }}
valueFrom:
secretKeyRef:
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-%s" .Release.Name "db") }}
key: {{ .Values.externalDatabase.existingSecret.hostKey }}
{{- else }}
value: {{ .Values.externalDatabase.host | quote }}
{{- end }}
- name: POSTGRES_DB
{{- if .Values.externalDatabase.existingSecret.databaseKey }}
valueFrom:
secretKeyRef:
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-%s" .Release.Name "db") }}
key: {{ .Values.externalDatabase.existingSecret.databaseKey }}
{{- else }}
value: {{ .Values.externalDatabase.database | quote }}
{{- end }}
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
Expand All @@ -125,9 +139,23 @@ Create environment variables used to configure the nextcloud container as well a
key: {{ .Values.externalDatabase.existingSecret.passwordKey | default "db-password" }}
{{- else }}
- name: MYSQL_HOST
{{- if .Values.externalDatabase.existingSecret.hostKey }}
valueFrom:
secretKeyRef:
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-%s" .Release.Name "db") }}
key: {{ .Values.externalDatabase.existingSecret.hostKey }}
{{- else }}
value: {{ .Values.externalDatabase.host | quote }}
{{- end }}
- name: MYSQL_DATABASE
{{- if .Values.externalDatabase.existingSecret.databaseKey }}
valueFrom:
secretKeyRef:
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-%s" .Release.Name "db") }}
key: {{ .Values.externalDatabase.existingSecret.databaseKey }}
{{- else }}
value: {{ .Values.externalDatabase.database | quote }}
{{- end }}
- name: MYSQL_USER
valueFrom:
secretKeyRef:
Expand Down
2 changes: 2 additions & 0 deletions charts/nextcloud/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ externalDatabase:
# secretName: nameofsecret
# usernameKey: db-username
# passwordKey: db-password
# hostKey: db-hostname-or-ip
# databaseKey: db-name

##
## MariaDB chart configuration
Expand Down

0 comments on commit 0c4de8f

Please sign in to comment.