From 0c1ec955e5d9253ce29f87b3685fac26704da2dd Mon Sep 17 00:00:00 2001 From: Michael Raimondi Date: Sun, 24 Jun 2018 10:20:03 -0400 Subject: [PATCH] [stable/prometheus-postgres-exporter] add support for Google Cloud SQL (#6009) * add support for Google Cloud SQL Cloud SQL, Google's managed database product, requires use of an authentication proxy when accessed from dynamic IPs. To limit access to the proxy, it is recommended to use a sidecar. More info: https://cloud.google.com/sql/docs/postgres/connect-kubernetes-engine Cloud SQL, like other managed databases, does not allow use of superuser accounts. Therefore, add support for a configurable database in `datasource`. More info: https://github.com/wrouesnel/postgres_exporter#running-as-non-superuser * re-bump chart version * use extraContainers & extraVolumes --- stable/prometheus-postgres-exporter/Chart.yaml | 2 +- stable/prometheus-postgres-exporter/README.md | 2 ++ .../templates/deployment.yaml | 10 ++++++++-- .../templates/secrets.yaml | 2 +- stable/prometheus-postgres-exporter/values.yaml | 7 +++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/stable/prometheus-postgres-exporter/Chart.yaml b/stable/prometheus-postgres-exporter/Chart.yaml index f5d1065a0d..1205b01d2d 100644 --- a/stable/prometheus-postgres-exporter/Chart.yaml +++ b/stable/prometheus-postgres-exporter/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "0.4.6" description: A Helm chart for prometheus postgres-exporter name: prometheus-postgres-exporter -version: 0.3.0 +version: 0.4.0 home: https://github.com/wrouesnel/postgres_exporter sources: - https://github.com/wrouesnel/postgres_exporter diff --git a/stable/prometheus-postgres-exporter/README.md b/stable/prometheus-postgres-exporter/README.md index bc25f1bec3..aa70d76604 100644 --- a/stable/prometheus-postgres-exporter/README.md +++ b/stable/prometheus-postgres-exporter/README.md @@ -55,6 +55,8 @@ The following table lists the configurable parameters of the postgres Exporter c | `nodeSelector` | node labels for pod assignment | `{}` | | `affinity` | node/pod affinities | `{}` | | `annotations` | Deployment annotations | `{}` | +| `extraContainers` | Additional sidecar containers | `""` | +| `extraVolumes` | Additional volumes for use in extraContainers | `""` | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, diff --git a/stable/prometheus-postgres-exporter/templates/deployment.yaml b/stable/prometheus-postgres-exporter/templates/deployment.yaml index 63a16c33d9..be5a3e09a1 100644 --- a/stable/prometheus-postgres-exporter/templates/deployment.yaml +++ b/stable/prometheus-postgres-exporter/templates/deployment.yaml @@ -29,7 +29,7 @@ spec: - name: {{ .Chart.Name }} args: - "--extend.query-path=/etc/config.yaml" - env: + env: - name: DATA_SOURCE_NAME valueFrom: secretKeyRef: @@ -55,6 +55,9 @@ spec: - name: queries mountPath: /etc/config.yaml subPath: config.yaml +{{- with .Values.extraContainers }} +{{ tpl . $ | indent 8 }} +{{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{ toYaml . | indent 8 }} @@ -71,4 +74,7 @@ spec: - configMap: defaultMode: 420 name: {{ template "prometheus-postgres-exporter.fullname" . }} - name: queries \ No newline at end of file + name: queries +{{- with .Values.extraVolumes }} +{{ tpl . $ | indent 6 }} +{{- end }} diff --git a/stable/prometheus-postgres-exporter/templates/secrets.yaml b/stable/prometheus-postgres-exporter/templates/secrets.yaml index cf8fe2f540..5bd51ed150 100644 --- a/stable/prometheus-postgres-exporter/templates/secrets.yaml +++ b/stable/prometheus-postgres-exporter/templates/secrets.yaml @@ -9,4 +9,4 @@ metadata: release: {{ .Release.Name }} type: Opaque data: - data_source_name: "{{ printf "postgresql://%s:%s@%s:%s/?sslmode=%s" .Values.config.datasource.user .Values.config.datasource.password .Values.config.datasource.host .Values.config.datasource.port .Values.config.datasource.sslmode | b64enc }}" + data_source_name: "{{ printf "postgresql://%s:%s@%s:%s/%s?sslmode=%s" .Values.config.datasource.user .Values.config.datasource.password .Values.config.datasource.host .Values.config.datasource.port .Values.config.datasource.database .Values.config.datasource.sslmode | b64enc }}" diff --git a/stable/prometheus-postgres-exporter/values.yaml b/stable/prometheus-postgres-exporter/values.yaml index 885153d7ed..b740095dce 100644 --- a/stable/prometheus-postgres-exporter/values.yaml +++ b/stable/prometheus-postgres-exporter/values.yaml @@ -44,6 +44,7 @@ config: user: password: port: "5432" + database: '' sslmode: disable # this are the defaults queries that the exporter will run, extracted from: https://github.com/wrouesnel/postgres_exporter/blob/master/queries.yaml queries: |- @@ -145,3 +146,9 @@ tolerations: [] affinity: {} annotations: {} + +# Additional sidecar containers, e. g. for a database proxy, such as Google's cloudsql-proxy +extraContainers: | + +# Additional volumes, e. g. for secrets used in an extraContainer +extraVolumes: |