From 75b823e8757bf321c9191bc6fd1e6d3865e79c5a Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Sat, 6 Apr 2019 15:08:27 -0400 Subject: [PATCH] MariaDB: Clean up values file and exporter start script This PS cleans up the default values file, and also allows some aspects of the mysql exporter's operation to be configured. Change-Id: I577e3237ca0bfe3665e7a57cf2a9364baea7c24a Signed-off-by: Pete Birley --- mariadb/templates/etc/_20-override.cnf.tpl | 2 +- .../prometheus/bin/_mysqld-exporter.sh.tpl | 14 ++++--------- .../prometheus/exporter-deployment.yaml | 11 ++++++++-- .../prometheus/exporter-service.yaml | 2 +- mariadb/values.yaml | 21 +++++++------------ 5 files changed, 22 insertions(+), 28 deletions(-) diff --git a/mariadb/templates/etc/_20-override.cnf.tpl b/mariadb/templates/etc/_20-override.cnf.tpl index 7c445fd65..209b55dd8 100644 --- a/mariadb/templates/etc/_20-override.cnf.tpl +++ b/mariadb/templates/etc/_20-override.cnf.tpl @@ -14,4 +14,4 @@ See the License for the specific language governing permissions and limitations under the License. */}} -{{ .Values.database.config_override }} +{{ .Values.conf.database.config_override }} diff --git a/mariadb/templates/monitoring/prometheus/bin/_mysqld-exporter.sh.tpl b/mariadb/templates/monitoring/prometheus/bin/_mysqld-exporter.sh.tpl index 6a7395fcc..b639c5bdc 100644 --- a/mariadb/templates/monitoring/prometheus/bin/_mysqld-exporter.sh.tpl +++ b/mariadb/templates/monitoring/prometheus/bin/_mysqld-exporter.sh.tpl @@ -17,14 +17,8 @@ limitations under the License. */}} set -ex -COMMAND="${@:-start}" -function start () { - exec /bin/mysqld_exporter -config.my-cnf=/etc/mysql/mysql_user.cnf -} - -function stop () { - kill -TERM 1 -} - -$COMMAND +exec /bin/mysqld_exporter \ + -config.my-cnf=/etc/mysql/mysql_user.cnf \ + -web.listen-address="${POD_IP}:${LISTEN_PORT}" \ + -web.telemetry-path="$TELEMETRY_PATH" diff --git a/mariadb/templates/monitoring/prometheus/exporter-deployment.yaml b/mariadb/templates/monitoring/prometheus/exporter-deployment.yaml index 50a31b6f2..275d1c798 100644 --- a/mariadb/templates/monitoring/prometheus/exporter-deployment.yaml +++ b/mariadb/templates/monitoring/prometheus/exporter-deployment.yaml @@ -54,10 +54,9 @@ spec: {{ tuple $envAll $envAll.Values.pod.resources.prometheus_mysql_exporter | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} command: - /tmp/mysqld-exporter.sh - - start ports: - name: metrics - containerPort: {{ .Values.network.prometheus_mysql_exporter.port }} + containerPort: {{ tuple "prometheus_mysql_exporter" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} env: - name: EXPORTER_USER valueFrom: @@ -74,6 +73,14 @@ spec: secretKeyRef: name: mysql-exporter-secrets key: DATA_SOURCE_NAME + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: LISTEN_PORT + value: {{ tuple "prometheus_mysql_exporter" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }} + - name: TELEMETRY_PATH + value: {{ tuple "prometheus_mysql_exporter" "internal" "metrics" . | include "helm-toolkit.endpoints.keystone_endpoint_path_lookup" | quote }} volumeMounts: - name: mysql-exporter-secrets mountPath: /etc/mysql/mysql_user.cnf diff --git a/mariadb/templates/monitoring/prometheus/exporter-service.yaml b/mariadb/templates/monitoring/prometheus/exporter-service.yaml index c040f2642..71bfd5cea 100644 --- a/mariadb/templates/monitoring/prometheus/exporter-service.yaml +++ b/mariadb/templates/monitoring/prometheus/exporter-service.yaml @@ -31,7 +31,7 @@ metadata: spec: ports: - name: metrics - port: {{ .Values.network.prometheus_mysql_exporter.port }} + port: {{ tuple "prometheus_mysql_exporter" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} selector: {{ tuple $envAll "prometheus_mysql_exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} {{- end }} diff --git a/mariadb/values.yaml b/mariadb/values.yaml index f1d57d0e6..a6f1effc1 100644 --- a/mariadb/values.yaml +++ b/mariadb/values.yaml @@ -226,8 +226,6 @@ dependencies: - endpoint: internal service: oslo_db -force_bootstrap: false - volume: chown_on_start: true enabled: true @@ -271,24 +269,19 @@ conf: --single-transaction --quick --skip-opt --add-drop-database --add-drop-table --databases days_of_backup_to_keep: 3 - -database: - config_override: null - # Any configuration here will override the base config. - # config_override: |- - # [mysqld] - # wsrep_slave_threads=1 + database: + config_override: null + # Any configuration here will override the base config. + # config_override: |- + # [mysqld] + # wsrep_slave_threads=1 monitoring: prometheus: - enabled: false + enabled: true mysqld_exporter: scrape: true -network: - prometheus_mysql_exporter: - port: 9104 - # typically overridden by environmental # values, but should include all endpoints # required by this chart