Skip to content

Commit 9e37127

Browse files
committed
Adding optional sslmode to db secrets, adding grafana-auth db secret to connect to pgsql
1 parent 89c0fa6 commit 9e37127

File tree

5 files changed

+49
-5
lines changed

5 files changed

+49
-5
lines changed

charts/sourcegraph/templates/_helpers.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ app.kubernetes.io/name: jaeger
211211
secretKeyRef:
212212
key: user
213213
name: {{ $secretName }}
214+
- name: {{ printf "%sSSLMODE" $prefix }}
215+
valueFrom:
216+
secretKeyRef:
217+
key: sslmode
218+
name: {{ $secretName }}
219+
optional: true
214220
{{- end }}
215221

216222
{{- define "sourcegraph.dataSource" -}}

charts/sourcegraph/templates/grafana/grafana.ConfigMap.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ data:
1717
url: http://{{ default "jaeger-query" .Values.jaeger.query.name }}:16686/-/debug/jaeger
1818
- name: pgsql
1919
type: postgres
20-
url: $PGHOST:$PGPORT
21-
user: $PGGRAFANAUSER
22-
database: $PGDATABASE
20+
url: $GRAFANA_PGSQL_HOST:$GRAFANA_PGSQL_PORT
21+
user: $GRAFANA_PGSQL_USER
22+
database: $GRAFANA_PGSQL_DATABASE
2323
secureJsonData:
24-
password: $PGGRAFANAPASSWORD
24+
password: $GRAFANA_PGSQL_PASSWORD
2525
jsonData:
26-
sslmode: $PGSSLMODE
26+
sslmode: $GRAFANA_PGSQL_SSLMODE
2727
kind: ConfigMap
2828
metadata:
2929
labels:

charts/sourcegraph/templates/grafana/grafana.StatefulSet.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ spec:
5353
terminationMessagePolicy: FallbackToLogsOnError
5454
env:
5555
{{- range $name, $item := .Values.grafana.env}}
56+
{{- include "sourcegraph.databaseAuth" (list . "grafana" "GRAFANA_PGSQL_") | nindent 8 }}
5657
- name: {{ $name }}
5758
{{- $item | toYaml | nindent 10 }}
5859
{{- end }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if and .Values.grafana.auth (not .Values.grafana.auth.existingSecret) }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: {{ .Values.grafana.name }}-auth
6+
labels:
7+
app: grafana
8+
deploy: sourcegraph
9+
app.kubernetes.io/component: grafana
10+
type: Opaque
11+
data:
12+
database: {{ .Values.grafana.auth.database | toString | b64enc | quote }}
13+
host: {{ .Values.grafana.auth.host | toString | b64enc | quote }}
14+
password: {{ .Values.grafana.auth.password | toString | b64enc | quote }}
15+
port: {{ .Values.grafana.auth.port | toString | b64enc | quote }}
16+
sslmode: {{ .Values.grafana.auth.sslmode | toString | b64enc | quote }}
17+
user: {{ .Values.grafana.auth.user | toString | b64enc | quote }}
18+
{{- end -}}

charts/sourcegraph/values.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,25 @@ gitserver:
424424
grafana:
425425
# -- Enable `grafana` dashboard (recommended)
426426
enabled: true
427+
# -- Sourcegraph Internal - Enable grafana to query pgsql database
428+
# -- NOTE: Create a separate user in the pgsql database with read-only perms on the minimum set of tables
429+
auth:
430+
# -- Name of existing secret to for Grafana to use to connect to the pgsql database
431+
# The secret must contain the keys `user`, `password`, `database`, `host` and `port`.
432+
# `auth.user`, `auth.password`, etc. are ignored if this is enabled
433+
existingSecret: ""
434+
# -- Sets postgres database name
435+
database: ""
436+
# -- Sets postgres host
437+
host: ""
438+
# -- Sets postgres username
439+
user: ""
440+
# -- Sets postgres password
441+
password: ""
442+
# -- Sets postgres port
443+
port: ""
444+
# -- Sets postgres sslmode
445+
sslmode: ""
427446
# -- Name of existing ConfigMap for `grafana`. It must contain a `datasources.yml` key.
428447
existingConfig: "" # Name of an existing configmap
429448
image:

0 commit comments

Comments
 (0)