From 074010fc4d98c37891133c4863039a125dd17d7e Mon Sep 17 00:00:00 2001 From: Akash LM Date: Tue, 7 Nov 2023 09:20:44 +0530 Subject: [PATCH] Add postgresql as a dependency --- charts/grafana/Chart.yaml | 7 ++++- charts/grafana/templates/_pod.tpl | 10 +++++++ charts/grafana/templates/configmap.yaml | 10 +++++++ charts/grafana/values.yaml | 37 +++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) diff --git a/charts/grafana/Chart.yaml b/charts/grafana/Chart.yaml index 72b8e0f..f10beb8 100644 --- a/charts/grafana/Chart.yaml +++ b/charts/grafana/Chart.yaml @@ -22,4 +22,9 @@ name: grafana sources: - https://github.com/grafana/grafana type: application -version: 1.0.3 +version: 1.0.4 +dependencies: + - name: postgresql + condition: postgresql.enabled + version: 1.0.0 + repository: https://kube-tarian.github.io/helmrepo-supporting-tools/ diff --git a/charts/grafana/templates/_pod.tpl b/charts/grafana/templates/_pod.tpl index 5f35d27..19c6a0d 100644 --- a/charts/grafana/templates/_pod.tpl +++ b/charts/grafana/templates/_pod.tpl @@ -381,6 +381,11 @@ containers: - name: config mountPath: "/etc/grafana/grafana.ini" subPath: grafana.ini + {{- if .Values.postgresql.enabled }} + - name: {{ .Values.database.secretMount.name }} + mountPath: {{ .Values.database.secretMount.mountPath }} + readOnly: {{ .Values.database.secretMount.readOnly }} + {{- end }} {{- if .Values.ldap.enabled }} - name: ldap mountPath: "/etc/grafana/ldap.toml" @@ -605,6 +610,11 @@ volumes: name: {{ tpl $name $root }} {{- end }} {{- end }} + {{- if .Values.postgresql.enabled }} + - name: {{ .Values.database.secretMount.name }} + secret: + secretName: {{ .Values.database.secretMount.secretName }} + {{- end }} {{- if .Values.ldap.enabled }} - name: ldap secret: diff --git a/charts/grafana/templates/configmap.yaml b/charts/grafana/templates/configmap.yaml index c72219f..e449a6a 100644 --- a/charts/grafana/templates/configmap.yaml +++ b/charts/grafana/templates/configmap.yaml @@ -14,6 +14,16 @@ data: plugins: {{ join "," .Values.plugins }} {{- end }} grafana.ini: | +{{- if .Values.postgresql.enabled }} + [database] + enabled = {{ .Values.postgresql.enabled }} + type = {{ .Values.database.type }} + host = {{ .Values.database.host }} + name = {{ .Values.database.name }} + ssl_mode = {{ .Values.database.ssl_mode }} + user = {{ .Values.database.user }} + password = {{ .Values.database.password }} +{{- end }} {{- range $key, $value := index .Values "grafana.ini" }} [{{ $key }}] {{- range $elem, $elemVal := $value }} diff --git a/charts/grafana/values.yaml b/charts/grafana/values.yaml index 72d1d79..349547a 100644 --- a/charts/grafana/values.yaml +++ b/charts/grafana/values.yaml @@ -876,3 +876,40 @@ extraObjects: [] # data: # - key: grafana-admin-password # name: adminPassword + +postgresql: + enabled: false + auth: + ## @param auth.enablePostgresUser Assign a password to the "postgres" admin user. Otherwise, remote access will be blocked for this user + ## + enablePostgresUser: true + ## @param auth.postgresPassword Password for the "postgres" admin user. Ignored if `auth.existingSecret` is provided + ## + postgresPassword: "" + ## @param auth.username Name for a custom user to create + ## + username: "" + ## @param auth.password Password for the custom user to create. Ignored if `auth.existingSecret` is provided + ## + password: "" + ## @param auth.database Name for a custom database to create + ## + database: "" + ## @param auth.existingSecret Name of existing secret to use for PostgreSQL credentials. `auth.postgresPassword`, `auth.password`, and `auth.replicationPassword` will be ignored and picked up from this secret. The secret might also contains the key `ldap-password` if LDAP is enabled. `ldap.bind_password` will be ignored and picked from this secret in this case. + ## + existingSecret: "" + metrics: + enabled: false + +database: + type: postgres + host: grafana-postgresql:5432 + name: postgres + ssl_mode: disable + user: postgres + password: $__file{/etc/secrets/postgresql/postgres-password} + secretMount: + name: postgresql-mount + mountPath: /etc/secrets/postgresql + secretName: grafana-postgresql + readOnly: true \ No newline at end of file