Set postgres credentials in nextcloud deployment

This commit is contained in:
Waqar Ahmed 2020-12-05 19:33:33 +05:00
parent 817de8f1b0
commit 0995fc4923
3 changed files with 12 additions and 6 deletions

View File

@ -49,19 +49,19 @@ spec:
{{- else }}
{{- if eq .Values.externalDatabase.type "postgresql" }}
- name: POSTGRES_HOST
value: {{ .Values.externalDatabase.host | quote }}
value: {{ template "nextcloud.fullname" . }}-postgres:5432
- name: POSTGRES_DB
value: {{ .Values.externalDatabase.database | quote }}
value: "nextcloud"
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-%s" .Release.Name "db") }}
key: {{ .Values.externalDatabase.existingSecret.usernameKey | default "db-username" }}
name: db-details
key: db-user
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-%s" .Release.Name "db") }}
key: {{ .Values.externalDatabase.existingSecret.passwordKey | default "db-password" }}
name: db-details
key: db-password
{{- end }}
{{- end }}
- name: NEXTCLOUD_ADMIN_USER

View File

@ -28,6 +28,11 @@ spec:
image: "postgres:13.1"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: db-details
key: db-user
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:

View File

@ -9,4 +9,5 @@ data:
# `index` function is necessary because the property name contains a dash.
# Otherwise (...).data.db_password would have worked too.
db-password: {{ index (lookup "v1" "Secret" .Release.Namespace "db-details").data "db-password" }}
db-user: postgres
{{ end }}