From cc1a168dcb964c5ca75257e4ccca69b2bbdd439f Mon Sep 17 00:00:00 2001 From: bitnami-bot Date: Mon, 18 Nov 2019 13:35:17 +0000 Subject: [PATCH] Synchronize upstreamed folder to 68dd2c849 --- upstreamed/postgresql/Chart.yaml | 2 +- upstreamed/postgresql/README.md | 1 + upstreamed/postgresql/templates/_helpers.tpl | 7 +++++++ .../postgresql/templates/metrics-configmap.yaml | 13 +++++++++++++ upstreamed/postgresql/templates/statefulset.yaml | 11 +++++++++++ upstreamed/postgresql/values-production.yaml | 12 ++++++++++++ upstreamed/postgresql/values.yaml | 12 ++++++++++++ 7 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 upstreamed/postgresql/templates/metrics-configmap.yaml diff --git a/upstreamed/postgresql/Chart.yaml b/upstreamed/postgresql/Chart.yaml index 28308f5d3..483913564 100644 --- a/upstreamed/postgresql/Chart.yaml +++ b/upstreamed/postgresql/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: postgresql -version: 7.2.0 +version: 7.3.0 appVersion: 11.6.0 description: Chart for PostgreSQL, an object-relational database management system (ORDBMS) with an emphasis on extensibility and on standards-compliance. keywords: diff --git a/upstreamed/postgresql/README.md b/upstreamed/postgresql/README.md index b66a854b1..bf1ba4782 100644 --- a/upstreamed/postgresql/README.md +++ b/upstreamed/postgresql/README.md @@ -178,6 +178,7 @@ The following tables lists the configurable parameters of the PostgreSQL chart a | `metrics.image.tag` | PostgreSQL Image tag | `{TAG_NAME}` | | `metrics.image.pullPolicy` | PostgreSQL Image pull policy | `IfNotPresent` | | `metrics.image.pullSecrets` | Specify Image pull secrets | `nil` (does not add image pull secrets to deployed pods) | +| `metrics.customMetrics` | Additional custom metrics | `nil` | | `metrics.securityContext.enabled` | Enable security context for metrics | `false` | | `metrics.securityContext.runAsUser` | User ID for the container for metrics | `1001` | | `metrics.livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 30 | diff --git a/upstreamed/postgresql/templates/_helpers.tpl b/upstreamed/postgresql/templates/_helpers.tpl index cf50989df..15ec51cb7 100644 --- a/upstreamed/postgresql/templates/_helpers.tpl +++ b/upstreamed/postgresql/templates/_helpers.tpl @@ -258,6 +258,13 @@ Get the initialization scripts Secret name. {{- printf "%s" (tpl .Values.initdbScriptsSecret $) -}} {{- end -}} +{{/* +Get the metrics ConfigMap name. +*/}} +{{- define "postgresql.metricsCM" -}} +{{- printf "%s-metrics" (include "postgresql.fullname" .) -}} +{{- end -}} + {{/* Return the proper Docker Image Registry Secret Names */}} diff --git a/upstreamed/postgresql/templates/metrics-configmap.yaml b/upstreamed/postgresql/templates/metrics-configmap.yaml new file mode 100644 index 000000000..524aa2f6a --- /dev/null +++ b/upstreamed/postgresql/templates/metrics-configmap.yaml @@ -0,0 +1,13 @@ +{{- if and .Values.metrics.enabled .Values.metrics.customMetrics }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "postgresql.metricsCM" . }} + labels: + app: {{ template "postgresql.name" . }} + chart: {{ template "postgresql.chart" . }} + release: {{ .Release.Name | quote }} + heritage: {{ .Release.Service | quote }} +data: + custom-metrics.yaml: {{ toYaml .Values.metrics.customMetrics | quote }} +{{- end }} diff --git a/upstreamed/postgresql/templates/statefulset.yaml b/upstreamed/postgresql/templates/statefulset.yaml index 4b2311faa..bdba9255a 100644 --- a/upstreamed/postgresql/templates/statefulset.yaml +++ b/upstreamed/postgresql/templates/statefulset.yaml @@ -335,6 +335,12 @@ spec: - name: postgresql-password mountPath: /opt/bitnami/postgresql/secrets/ {{- end }} + {{- if .Values.metrics.customMetrics }} + - name: custom-metrics + mountPath: /conf + readOnly: true + args: ["--extend.query-path", "/conf/custom-metrics.yaml"] + {{- end }} ports: - name: metrics containerPort: 9187 @@ -371,6 +377,11 @@ spec: {{- if .Values.master.extraVolumes }} {{- toYaml .Values.master.extraVolumes | nindent 8 }} {{- end }} +{{- if and .Values.metrics.enabled .Values.metrics.customMetrics }} + - name: custom-metrics + configMap: + name: {{ template "postgresql.metricsCM" . }} +{{- end }} {{- if and .Values.persistence.enabled .Values.persistence.existingClaim }} - name: data persistentVolumeClaim: diff --git a/upstreamed/postgresql/values-production.yaml b/upstreamed/postgresql/values-production.yaml index eb2a661a5..0d92a7c35 100644 --- a/upstreamed/postgresql/values-production.yaml +++ b/upstreamed/postgresql/values-production.yaml @@ -385,6 +385,18 @@ metrics: ## # pullSecrets: # - myRegistryKeySecretName + ## Define additional custom metrics + ## ref: https://github.com/wrouesnel/postgres_exporter#adding-new-metrics-via-a-config-file + # customMetrics: + # pg_database: + # query: "SELECT d.datname AS name, CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT') THEN pg_catalog.pg_database_size(d.datname) ELSE 0 END AS size FROM pg_catalog.pg_database d where datname not in ('template0', 'template1', 'postgres')" + # metrics: + # - name: + # usage: "LABEL" + # description: "Name of the database" + # - size_bytes: + # usage: "GAUGE" + # description: "Size of the database in bytes" ## Pod Security Context ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ ## diff --git a/upstreamed/postgresql/values.yaml b/upstreamed/postgresql/values.yaml index 3487150e8..471f353dd 100644 --- a/upstreamed/postgresql/values.yaml +++ b/upstreamed/postgresql/values.yaml @@ -385,6 +385,18 @@ metrics: ## # pullSecrets: # - myRegistryKeySecretName + ## Define additional custom metrics + ## ref: https://github.com/wrouesnel/postgres_exporter#adding-new-metrics-via-a-config-file + # customMetrics: + # pg_database: + # query: "SELECT d.datname AS name, CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT') THEN pg_catalog.pg_database_size(d.datname) ELSE 0 END AS size FROM pg_catalog.pg_database d where datname not in ('template0', 'template1', 'postgres')" + # metrics: + # - name: + # usage: "LABEL" + # description: "Name of the database" + # - size_bytes: + # usage: "GAUGE" + # description: "Size of the database in bytes" ## Pod Security Context ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ ##