Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,24 @@ Get PostgreSQL user
{{- end -}}

{{/*
Get PostgreSQL password
Get PostgreSQL password value
*/}}
{{- define "cvms.postgresql.password" -}}
{{- ternary .Values.postgresql.auth.password .Values.postgresql.external.password .Values.postgresql.enabled | quote -}}
{{- define "cvms.postgresql.password.value" -}}
{{- if .Values.postgresql.enabled -}}
{{- if not .Values.postgresql.auth.existingSecret -}}
{{- if .Values.postgresql.auth.password -}}
{{ .Values.postgresql.auth.password | quote }}
{{- else -}}
{{- fail "PostgreSQL password must be set either through postgresql.auth.password or postgresql.auth.existingSecret when postgresql.enabled is true" -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- if .Values.postgresql.external.password -}}
{{ .Values.postgresql.external.password | quote }}
{{- else -}}
{{- fail "PostgreSQL external password must be set when postgresql.enabled is false" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Expand Down
31 changes: 24 additions & 7 deletions helm/templates/indexer/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,30 @@ spec:
spec:
{{- if .Values.indexer.initContainers.enabled }}
initContainers:
{{- range .Values.indexer.initContainers.containers }}
{{- range .Values.indexer.initContainers.containers }}
- name: {{ .name }}
image: {{ .image }}
imagePullPolicy: {{ .imagePullPolicy }}
command:
{{- toYaml .command | nindent 10 }}
{{- toYaml .command | nindent 12 }}
args:
{{- toYaml .args | nindent 10 }}
{{- toYaml .args | nindent 12 }}
env:
- name: DB_PASSWORD
{{- if and $.Values.postgresql.enabled $.Values.postgresql.auth.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ $.Values.postgresql.auth.existingSecret }}
key: password
{{- else }}
value: {{ include "cvms.postgresql.password.value" $ }}
{{- end }}
volumeMounts:
{{- range .volumeMounts }}
{{- range .volumeMounts }}
- name: {{ .name }}
mountPath: {{ .mountPath | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down Expand Up @@ -76,7 +86,14 @@ spec:
- name: DB_NAME
value: {{ include "cvms.postgresql.database" . }}
- name: DB_PASSWORD
value: {{ include "cvms.postgresql.password" . }}
{{- if and .Values.postgresql.enabled .Values.postgresql.auth.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.postgresql.auth.existingSecret }}
key: password
{{- else }}
value: {{ include "cvms.postgresql.password.value" . }}
{{- end }}
- name: DB_PORT
value: {{ include "cvms.postgresql.port" . }}
- name: DB_USER
Expand Down
1 change: 0 additions & 1 deletion helm/templates/sql-schema-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ data:
DB_PORT={{ include "cvms.postgresql.port" . }}
DB_USER={{ include "cvms.postgresql.user" . }}
DB_NAME={{ include "cvms.postgresql.database" . }}
DB_PASSWORD={{ include "cvms.postgresql.password" . }}

# GitHub API URL for the schema directory
SCHEMA_API_URL="https://api.github.com/repos/cosmostation/cvms/contents/docker/postgres/schema"
Expand Down
6 changes: 3 additions & 3 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ postgresql:
## All of these values are only used when postgresql.enabled is set to false
## @param postgresql.external.host Database host
## @param postgresql.external.port Database port number
## @param postgresql.external.user Non-root username for Kong
## @param postgresql.external.password Password for the non-root username for Kong
## @param postgresql.external.database Kong database name
## @param postgresql.external.user Non-root username
## @param postgresql.external.password Password for the non-root username
## @param postgresql.external.database database name
## @param postgresql.external.existingSecret Name of an existing secret resource containing the database credentials
## @param postgresql.external.existingSecretPasswordKey Name of an existing secret key containing the database credentials
##
Expand Down