diff --git a/stable/prometheus-mysql-exporter/Chart.yaml b/stable/prometheus-mysql-exporter/Chart.yaml index 0de7485e49..cef9af6113 100644 --- a/stable/prometheus-mysql-exporter/Chart.yaml +++ b/stable/prometheus-mysql-exporter/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 description: A Helm chart for prometheus mysql exporter with cloudsqlproxy name: prometheus-mysql-exporter -version: 0.5.1 +version: 0.5.2 home: https://github.com/prometheus/mysqld_exporter appVersion: v0.11.0 sources: diff --git a/stable/prometheus-mysql-exporter/README.md b/stable/prometheus-mysql-exporter/README.md index 95e1981173..a1f78c7598 100644 --- a/stable/prometheus-mysql-exporter/README.md +++ b/stable/prometheus-mysql-exporter/README.md @@ -57,6 +57,7 @@ The following table lists the configurable parameters of the mysql exporter char | `mysql.port` | MySQL connection port | `3306` | | `mysql.protocol` | MySQL connection protocol (optional) | `""` | | `mysql.user` | MySQL connection username | `exporter` | +| `mysql.existingSecret` | Use existing kubernetes secret for DATA_SOURCE_NAME | `false` | | `cloudsqlproxy.enabled` | Flag to enable the connection using Cloud SQL Proxy | `false` | | `cloudsqlproxy.image.repo` | Cloud SQL Proxy image repository | `gcr.io/cloudsql-docker/gce-proxy` | | `cloudsqlproxy.image.tag` | Cloud SQL Proxy image tag | `1.14` | diff --git a/stable/prometheus-mysql-exporter/templates/_helpers.tpl b/stable/prometheus-mysql-exporter/templates/_helpers.tpl index 9fcb0a922b..214c3bf21b 100644 --- a/stable/prometheus-mysql-exporter/templates/_helpers.tpl +++ b/stable/prometheus-mysql-exporter/templates/_helpers.tpl @@ -37,3 +37,14 @@ Secret name for cloudsql credentials {{- define "prometheus-mysql-exporter.cloudsqlsecret" -}} {{ template "prometheus-mysql-exporter.fullname" . }}-cloudsqlsecret {{- end -}} + +{{/* +Secret name for DATA_SOURCE_NAME +*/}} +{{- define "prometheus-mysql-exporter.secret" -}} + {{- if .Values.mysql.existingSecret -}} + {{- printf "%s" .Values.mysql.existingSecret -}} + {{- else -}} + {{ template "prometheus-mysql-exporter.fullname" . }} + {{- end -}} +{{- end -}} \ No newline at end of file diff --git a/stable/prometheus-mysql-exporter/templates/deployment.yaml b/stable/prometheus-mysql-exporter/templates/deployment.yaml index 3639220146..8fa969e3e1 100644 --- a/stable/prometheus-mysql-exporter/templates/deployment.yaml +++ b/stable/prometheus-mysql-exporter/templates/deployment.yaml @@ -50,7 +50,7 @@ spec: {{- end }} envFrom: - secretRef: - name: {{ template "prometheus-mysql-exporter.fullname" . }} + name: {{ template "prometheus-mysql-exporter.secret" . }} ports: - containerPort: {{ .Values.service.internalPort }} livenessProbe: diff --git a/stable/prometheus-mysql-exporter/templates/secret-env.yaml b/stable/prometheus-mysql-exporter/templates/secret-env.yaml index bd3914937b..83789725e6 100644 --- a/stable/prometheus-mysql-exporter/templates/secret-env.yaml +++ b/stable/prometheus-mysql-exporter/templates/secret-env.yaml @@ -1,3 +1,4 @@ +{{- if or (not .Values.mysql.existingSecret) }} apiVersion: v1 kind: Secret metadata: @@ -5,3 +6,4 @@ metadata: type: Opaque stringData: DATA_SOURCE_NAME: "{{ .Values.mysql.user }}:{{ .Values.mysql.pass }}@{{ if .Values.mysql.protocol }}{{ .Values.mysql.protocol }}{{ end }}({{ .Values.mysql.host }}:{{ .Values.mysql.port }})/{{ if .Values.mysql.db }}{{ .Values.mysql.db }}{{ end }}{{ if .Values.mysql.param }}?{{ .Values.mysql.param }}{{ end }}" +{{- end }} \ No newline at end of file diff --git a/stable/prometheus-mysql-exporter/values.yaml b/stable/prometheus-mysql-exporter/values.yaml index 1f2309f646..9b8afd9fde 100644 --- a/stable/prometheus-mysql-exporter/values.yaml +++ b/stable/prometheus-mysql-exporter/values.yaml @@ -99,6 +99,7 @@ mysql: port: 3306 protocol: "" user: "exporter" + existingSecret: false # cloudsqlproxy https://cloud.google.com/sql/docs/mysql/sql-proxy cloudsqlproxy: