From b42cd19bdc6910fa24994428f3ede60fd457a4ee Mon Sep 17 00:00:00 2001 From: Steve Wilkerson Date: Sat, 6 Jan 2018 13:12:15 -0600 Subject: [PATCH] Add prometheus exporters to osh charts This moves the prometheus exporters for services into a directory in the chart themselves. This keeps the monitoring services coupled to the services theyre meant to monitor. This changes the chart directory structure to include a monitoring/ directory to host any monitoring requirements (not just prometheus exporters) Change-Id: Ic5f46a7e9a2a773a837ff399b8730782cf89f1de --- .../prometheus/bin/_create-mysql-user.sh.tpl | 24 ++++ .../prometheus/bin/_mysqld-exporter.sh.tpl | 30 +++++ .../prometheus/exporter-configmap-bin.yaml | 29 +++++ .../prometheus/exporter-deployment.yaml | 88 ++++++++++++++ .../prometheus/exporter-job-create-user.yaml | 85 +++++++++++++ .../prometheus/exporter-secrets-etc.yaml | 35 ++++++ .../prometheus/exporter-service.yaml | 37 ++++++ .../prometheus/secrets/_exporter_user.cnf.tpl | 21 ++++ mariadb/templates/statefulset.yaml | 2 +- mariadb/values.yaml | 114 +++++++++++++++++- .../prometheus/exporter-deployment.yaml | 66 ++++++++++ .../prometheus/exporter-service.yaml | 37 ++++++ rabbitmq/templates/statefulset.yaml | 2 +- rabbitmq/values.yaml | 99 ++++++++++++++- 14 files changed, 663 insertions(+), 6 deletions(-) create mode 100644 mariadb/templates/monitoring/prometheus/bin/_create-mysql-user.sh.tpl create mode 100644 mariadb/templates/monitoring/prometheus/bin/_mysqld-exporter.sh.tpl create mode 100644 mariadb/templates/monitoring/prometheus/exporter-configmap-bin.yaml create mode 100644 mariadb/templates/monitoring/prometheus/exporter-deployment.yaml create mode 100644 mariadb/templates/monitoring/prometheus/exporter-job-create-user.yaml create mode 100644 mariadb/templates/monitoring/prometheus/exporter-secrets-etc.yaml create mode 100644 mariadb/templates/monitoring/prometheus/exporter-service.yaml create mode 100644 mariadb/templates/monitoring/prometheus/secrets/_exporter_user.cnf.tpl create mode 100644 rabbitmq/templates/monitoring/prometheus/exporter-deployment.yaml create mode 100644 rabbitmq/templates/monitoring/prometheus/exporter-service.yaml diff --git a/mariadb/templates/monitoring/prometheus/bin/_create-mysql-user.sh.tpl b/mariadb/templates/monitoring/prometheus/bin/_create-mysql-user.sh.tpl new file mode 100644 index 0000000000..49773d0a11 --- /dev/null +++ b/mariadb/templates/monitoring/prometheus/bin/_create-mysql-user.sh.tpl @@ -0,0 +1,24 @@ +#!/bin/bash + +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +set -ex + +mysql --defaults-file=/etc/mysql/admin_user.cnf -e \ + "CREATE OR REPLACE USER '${EXPORTER_USER}'@'%' IDENTIFIED BY '${EXPORTER_PASSWORD}'; \ + GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO '${EXPORTER_USER}'@'%'; \ + FLUSH PRIVILEGES;" diff --git a/mariadb/templates/monitoring/prometheus/bin/_mysqld-exporter.sh.tpl b/mariadb/templates/monitoring/prometheus/bin/_mysqld-exporter.sh.tpl new file mode 100644 index 0000000000..6a7395fcc2 --- /dev/null +++ b/mariadb/templates/monitoring/prometheus/bin/_mysqld-exporter.sh.tpl @@ -0,0 +1,30 @@ +#!/bin/sh + +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +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 diff --git a/mariadb/templates/monitoring/prometheus/exporter-configmap-bin.yaml b/mariadb/templates/monitoring/prometheus/exporter-configmap-bin.yaml new file mode 100644 index 0000000000..169f8e56a6 --- /dev/null +++ b/mariadb/templates/monitoring/prometheus/exporter-configmap-bin.yaml @@ -0,0 +1,29 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +{{- if and .Values.manifests.monitoring.prometheus.configmap_bin .Values.monitoring.prometheus.enabled }} +{{- $envAll := . }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: mysql-exporter-bin +data: + create-mysql-user.sh: | +{{ tuple "bin/_create-mysql-user.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} + mysqld-exporter.sh: | +{{ tuple "bin/_mysqld-exporter.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} +{{- end }} diff --git a/mariadb/templates/monitoring/prometheus/exporter-deployment.yaml b/mariadb/templates/monitoring/prometheus/exporter-deployment.yaml new file mode 100644 index 0000000000..72f4492402 --- /dev/null +++ b/mariadb/templates/monitoring/prometheus/exporter-deployment.yaml @@ -0,0 +1,88 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +{{- if and .Values.manifests.monitoring.prometheus.deployment_exporter .Values.monitoring.prometheus.enabled }} +{{- $envAll := . }} +{{- $dependencies := .Values.dependencies.prometheus_mysql_exporter }} + +{{- $serviceAccountName := "prometheus-mysql-exporter"}} +{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: prometheus-mysql-exporter +spec: + replicas: {{ .Values.pod.replicas.prometheus_mysql_exporter }} +{{ tuple $envAll | include "helm-toolkit.snippets.kubernetes_upgrades_deployment" | indent 2 }} + template: + metadata: + labels: +{{ tuple $envAll "prometheus_mysql_exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} + namespace: {{ .Values.endpoints.prometheus_mysql_exporter.namespace }} + spec: + serviceAccountName: {{ $serviceAccountName }} + nodeSelector: + {{ .Values.labels.prometheus_mysql_exporter.node_selector_key }}: {{ .Values.labels.prometheus_mysql_exporter.node_selector_value }} + terminationGracePeriodSeconds: {{ .Values.pod.lifecycle.termination_grace_period.prometheus_mysql_exporter.timeout | default "30" }} + initContainers: +{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} + containers: + - name: mysql-exporter + image: {{ .Values.images.tags.prometheus_mysql_exporter }} + imagePullPolicy: {{ .Values.images.pull_policy }} +{{ 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 }} + env: + - name: EXPORTER_USER + valueFrom: + secretKeyRef: + name: mysql-exporter-secrets + key: EXPORTER_USER + - name: EXPORTER_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-exporter-secrets + key: EXPORTER_PASSWORD + - name: DATA_SOURCE_NAME + valueFrom: + secretKeyRef: + name: mysql-exporter-secrets + key: DATA_SOURCE_NAME + volumeMounts: + - name: mysql-exporter-secrets + mountPath: /etc/mysql/mysql_user.cnf + subPath: mysql_user.cnf + readOnly: true + - name: mysql-exporter-bin + mountPath: /tmp/mysqld-exporter.sh + subPath: mysqld-exporter.sh + readOnly: true + volumes: + - name: mysql-exporter-secrets + secret: + secretName: mysql-exporter-secrets + defaultMode: 0444 + - name: mysql-exporter-bin + configMap: + name: mysql-exporter-bin + defaultMode: 0555 +{{- end }} diff --git a/mariadb/templates/monitoring/prometheus/exporter-job-create-user.yaml b/mariadb/templates/monitoring/prometheus/exporter-job-create-user.yaml new file mode 100644 index 0000000000..64b2eb14b5 --- /dev/null +++ b/mariadb/templates/monitoring/prometheus/exporter-job-create-user.yaml @@ -0,0 +1,85 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +{{- if and .Values.manifests.monitoring.prometheus.job_user_create .Values.monitoring.prometheus.enabled }} +{{- $envAll := . }} +{{- $dependencies := .Values.dependencies.prometheus_create_mysql_user }} + +{{- $serviceAccountName := "exporter-create-sql-user" }} +{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: exporter-create-sql-user +spec: + template: + metadata: + labels: +{{ tuple $envAll "prometheus_mysql_exporter" "create-sql-user" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} + spec: + serviceAccountName: {{ $serviceAccountName }} + restartPolicy: OnFailure + nodeSelector: + {{ .Values.labels.prometheus_mysql_exporter.node_selector_key }}: {{ .Values.labels.prometheus_mysql_exporter.node_selector_value }} + initContainers: +{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} + containers: + - name: exporter-create-sql-user + image: {{ .Values.images.tags.prometheus_create_mysql_user }} + imagePullPolicy: {{ .Values.images.pull_policy }} +{{ tuple $envAll $envAll.Values.pod.resources.jobs.prometheus_create_mysql_user | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} + command: + - /tmp/create-mysql-user.sh + env: + - name: EXPORTER_USER + valueFrom: + secretKeyRef: + name: mysql-exporter-secrets + key: EXPORTER_USER + - name: EXPORTER_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-exporter-secrets + key: EXPORTER_PASSWORD + - name: MYSQL_SERVICE + value: {{ tuple "oslo_db" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} + - name: MYSQL_ROOT_USER + value: {{ .Values.endpoints.oslo_db.auth.admin.username }} + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mariadb-db-root-password + key: MYSQL_ROOT_PASSWORD + volumeMounts: + - name: mysql-exporter-bin + mountPath: /tmp/create-mysql-user.sh + subPath: create-mysql-user.sh + readOnly: true + - name: mariadb-secrets + mountPath: /etc/mysql/admin_user.cnf + subPath: admin_user.cnf + readOnly: true + volumes: + - name: mysql-exporter-bin + configMap: + name: mysql-exporter-bin + defaultMode: 0555 + - name: mariadb-secrets + secret: + secretName: mariadb-secrets + defaultMode: 0444 +{{- end }} diff --git a/mariadb/templates/monitoring/prometheus/exporter-secrets-etc.yaml b/mariadb/templates/monitoring/prometheus/exporter-secrets-etc.yaml new file mode 100644 index 0000000000..4a454096cd --- /dev/null +++ b/mariadb/templates/monitoring/prometheus/exporter-secrets-etc.yaml @@ -0,0 +1,35 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +{{- if and .Values.manifests.monitoring.prometheus.secret_etc .Values.monitoring.prometheus.enabled }} +{{- $envAll := . }} + +{{- $exporter_user := .Values.endpoints.oslo_db.auth.exporter.username }} +{{- $exporter_password := .Values.endpoints.oslo_db.auth.exporter.password }} +{{- $db_host := tuple "oslo_db" "internal" "mysql" $envAll | include "helm-toolkit.endpoints.host_and_port_endpoint_uri_lookup" }} +{{- $data_source_name := printf "%s:%s@(%s)/" $exporter_user $exporter_password $db_host }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: mysql-exporter-secrets +type: Opaque +data: + DATA_SOURCE_NAME: {{ $data_source_name | b64enc }} + EXPORTER_USER: {{ .Values.endpoints.oslo_db.auth.exporter.username | b64enc }} + EXPORTER_PASSWORD: {{ .Values.endpoints.oslo_db.auth.exporter.password | b64enc }} + mysql_user.cnf: {{ tuple "secrets/_exporter_user.cnf.tpl" . | include "helm-toolkit.utils.template" | b64enc }} +{{- end }} diff --git a/mariadb/templates/monitoring/prometheus/exporter-service.yaml b/mariadb/templates/monitoring/prometheus/exporter-service.yaml new file mode 100644 index 0000000000..c040f2642e --- /dev/null +++ b/mariadb/templates/monitoring/prometheus/exporter-service.yaml @@ -0,0 +1,37 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +{{- if and .Values.manifests.monitoring.prometheus.service_exporter .Values.monitoring.prometheus.enabled }} +{{- $envAll := . }} +{{- $prometheus_annotations := $envAll.Values.monitoring.prometheus.mysqld_exporter }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ tuple "prometheus_mysql_exporter" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} + labels: +{{ tuple $envAll "prometheus_mysql_exporter" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} + annotations: +{{- if .Values.monitoring.prometheus.enabled }} +{{ tuple $prometheus_annotations | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }} +{{- end }} +spec: + ports: + - name: metrics + port: {{ .Values.network.prometheus_mysql_exporter.port }} + selector: +{{ tuple $envAll "prometheus_mysql_exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} +{{- end }} diff --git a/mariadb/templates/monitoring/prometheus/secrets/_exporter_user.cnf.tpl b/mariadb/templates/monitoring/prometheus/secrets/_exporter_user.cnf.tpl new file mode 100644 index 0000000000..8d12239d1f --- /dev/null +++ b/mariadb/templates/monitoring/prometheus/secrets/_exporter_user.cnf.tpl @@ -0,0 +1,21 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +[client] +user = {{ .Values.endpoints.prometheus_mysql_exporter.auth.user.username }} +password = {{ .Values.endpoints.prometheus_mysql_exporter.auth.user.password }} +host = {{ tuple "oslo_db" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} +port = {{ tuple "oslo_db" "internal" "mysql" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} diff --git a/mariadb/templates/statefulset.yaml b/mariadb/templates/statefulset.yaml index 472279563a..31a4a7cc5a 100644 --- a/mariadb/templates/statefulset.yaml +++ b/mariadb/templates/statefulset.yaml @@ -37,7 +37,7 @@ spec: affinity: {{ tuple $envAll "mariadb" "server" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }} nodeSelector: - {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} + {{ .Values.labels.server.node_selector_key }}: {{ .Values.labels.server.node_selector_value }} initContainers: {{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} {{- if .Values.volume.chown_on_start }} diff --git a/mariadb/values.yaml b/mariadb/values.yaml index 429e09b3f3..9c5896abfa 100644 --- a/mariadb/values.yaml +++ b/mariadb/values.yaml @@ -15,12 +15,19 @@ images: tags: mariadb: docker.io/mariadb:10.1.23 + prometheus_create_mysql_user: docker.io/mariadb:10.1.23 + prometheus_mysql_exporter: docker.io/prom/mysqld-exporter:v0.10.0 + prometheus_mysql_exporter_helm_tests: docker.io/kolla/ubuntu-source-heat-engine:3.0.3 dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.2.1 pull_policy: IfNotPresent labels: - node_selector_key: openstack-control-plane - node_selector_value: enabled + server: + node_selector_key: openstack-control-plane + node_selector_value: enabled + prometheus_mysql_exporter: + node_selector_key: openstack-control-plane + node_selector_value: enabled pod: affinity: @@ -31,12 +38,30 @@ pod: default: kubernetes.io/hostname replicas: server: 3 + prometheus_mysql_exporter: 1 lifecycle: + upgrades: + deployments: + revision_history: 3 + pod_replacement_strategy: RollingUpdate + rolling_update: + max_unavailable: 1 + max_surge: 3 + termination_grace_period: + prometheus_mysql_exporter: + timeout: 30 disruption_budget: mariadb: min_available: 0 resources: enabled: false + prometheus_mysql_exporter: + limits: + memory: "1024Mi" + cpu: "2000m" + requests: + memory: "128Mi" + cpu: "500m" server: requests: memory: "128Mi" @@ -44,11 +69,42 @@ pod: limits: memory: "1024Mi" cpu: "2000m" + jobs: + tests: + limits: + memory: "1024Mi" + cpu: "2000m" + requests: + memory: "128Mi" + cpu: "100m" + prometheus_create_mysql_user: + limits: + memory: "1024Mi" + cpu: "2000m" + requests: + memory: "128Mi" + cpu: "100m" dependencies: mariadb: jobs: null services: null + prometheus_mysql_exporter: + services: + - service: oslo_db + endpoint: internal + jobs: + - exporter-create-sql-user + prometheus_mysql_exporter_tests: + services: + - service: prometheus_mysql_exporter + endpoint: internal + - service: monitoring + endpoint: internal + prometheus_create_mysql_user: + services: + - service: oslo_db + endpoint: internal force_bootstrap: false @@ -65,16 +121,63 @@ database: # [mysqld] # wsrep_slave_threads=1 +monitoring: + prometheus: + enabled: false + mysqld_exporter: + scrape: true + +network: + prometheus_mysql_exporter: + port: 9104 + # typically overriden by environmental # values, but should include all endpoints # required by this chart endpoints: cluster_domain_suffix: cluster.local + monitoring: + name: prometheus + namespace: null + hosts: + default: prom-metrics + public: prometheus + host_fqdn_override: + default: null + path: + default: null + scheme: + default: 'http' + port: + api: + default: 9090 + public: 80 + prometheus_mysql_exporter: + namespace: null + auth: + user: + username: exporter + password: password + hosts: + default: mysql-exporter + host_fqdn_override: + default: null + path: + default: /metrics + scheme: + default: 'http' + port: + metrics: + default: 9104 oslo_db: + namespace: null auth: admin: username: root password: password + exporter: + username: exporter + password: password hosts: default: mariadb discovery: mariadb-discovery @@ -92,6 +195,13 @@ manifests: configmap_bin: true configmap_etc: true pdb_server: true + monitoring: + prometheus: + configmap_bin: true + deployment_exporter: true + job_user_create: true + secret_etc: true + service_exporter: true secret_db: true secret_etc: true service_discovery: true diff --git a/rabbitmq/templates/monitoring/prometheus/exporter-deployment.yaml b/rabbitmq/templates/monitoring/prometheus/exporter-deployment.yaml new file mode 100644 index 0000000000..a86542bb28 --- /dev/null +++ b/rabbitmq/templates/monitoring/prometheus/exporter-deployment.yaml @@ -0,0 +1,66 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +{{- if and .Values.manifests.monitoring.prometheus.deployment_exporter .Values.monitoring.prometheus.enabled }} +{{- $envAll := . }} +{{- $dependencies := .Values.dependencies.prometheus_rabbitmq_exporter }} + +{{- $rcControllerName := printf "%s-%s" $envAll.Release.Name "rabbitmq-exporter" }} +{{ tuple $envAll $dependencies $rcControllerName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ $rcControllerName | quote }} +spec: + replicas: {{ .Values.pod.replicas.prometheus_rabbitmq_exporter }} +{{ tuple $envAll | include "helm-toolkit.snippets.kubernetes_upgrades_deployment" | indent 2 }} + template: + metadata: + labels: +{{ tuple $envAll "prometheus_rabbitmq_exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} + namespace: {{ .Values.endpoints.prometheus_rabbitmq_exporter.namespace }} + spec: + serviceAccountName: {{ $rcControllerName | quote }} + nodeSelector: + {{ .Values.labels.prometheus_rabbitmq_exporter.node_selector_key }}: {{ .Values.labels.prometheus_rabbitmq_exporter.node_selector_value }} + terminationGracePeriodSeconds: {{ .Values.pod.lifecycle.termination_grace_period.prometheus_rabbitmq_exporter.timeout | default "30" }} + initContainers: +{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} + containers: + - name: rabbitmq-exporter + image: {{ .Values.images.tags.prometheus_rabbitmq_exporter }} + imagePullPolicy: {{ .Values.images.pull_policy }} +{{ tuple $envAll $envAll.Values.pod.resources.prometheus_rabbitmq_exporter | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} + ports: + - name: metrics + containerPort: {{ .Values.network.prometheus_rabbitmq_exporter.port }} + env: + - name: RABBIT_URL + value: http://{{ tuple "oslo_messaging" "internal" . | include "helm-toolkit.endpoints.hostname_fqdn_endpoint_lookup" }}:15672 + - name: RABBIT_USER + value: {{ .Values.endpoints.oslo_messaging.auth.user.username | quote }} + - name: RABBIT_PASSWORD + value: {{ .Values.endpoints.oslo_messaging.auth.user.password | quote }} + - name: RABBIT_CAPABILITIES + value: {{ tuple .Values.conf.prometheus_exporter.capabilities $envAll | include "helm-toolkit.utils.joinListWithComma" | quote }} + - name: PUBLISH_PORT + value: {{ .Values.network.prometheus_rabbitmq_exporter.port | quote }} + - name: LOG_LEVEL + value: {{ .Values.conf.prometheus_exporter.log_level | quote }} + - name: SKIPVERIFY + value: {{ .Values.conf.prometheus_exporter.skipverify | quote }} +{{- end }} diff --git a/rabbitmq/templates/monitoring/prometheus/exporter-service.yaml b/rabbitmq/templates/monitoring/prometheus/exporter-service.yaml new file mode 100644 index 0000000000..fbcc21f227 --- /dev/null +++ b/rabbitmq/templates/monitoring/prometheus/exporter-service.yaml @@ -0,0 +1,37 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +{{- if and .Values.manifests.monitoring.prometheus.service_exporter .Values.monitoring.prometheus.enabled }} +{{- $envAll := . }} +{{- $prometheus_annotations := $envAll.Values.monitoring.prometheus.rabbitmq_exporter }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ tuple "prometheus_rabbitmq_exporter" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} + labels: +{{ tuple $envAll "prometheus_rabbitmq_exporter" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} + annotations: +{{- if .Values.monitoring.prometheus.enabled }} +{{ tuple $prometheus_annotations | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }} +{{- end }} +spec: + ports: + - name: metrics + port: {{ .Values.network.prometheus_rabbitmq_exporter.port }} + selector: +{{ tuple $envAll "prometheus_rabbitmq_exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} +{{- end }} diff --git a/rabbitmq/templates/statefulset.yaml b/rabbitmq/templates/statefulset.yaml index 0a50902ed2..83ea34f85e 100644 --- a/rabbitmq/templates/statefulset.yaml +++ b/rabbitmq/templates/statefulset.yaml @@ -72,7 +72,7 @@ spec: affinity: {{ tuple $envAll "rabbitmq" "server" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }} nodeSelector: - {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} + {{ .Values.labels.server.node_selector_key }}: {{ .Values.labels.server.node_selector_value }} initContainers: {{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 9 }} containers: diff --git a/rabbitmq/values.yaml b/rabbitmq/values.yaml index 509c4bd55e..78ddd61efe 100644 --- a/rabbitmq/values.yaml +++ b/rabbitmq/values.yaml @@ -18,11 +18,17 @@ # name: value labels: - node_selector_key: openstack-control-plane - node_selector_value: enabled + server: + node_selector_key: openstack-control-plane + node_selector_value: enabled + prometheus_rabbitmq_exporter: + node_selector_key: openstack-control-plane + node_selector_value: enabled images: tags: + prometheus_rabbitmq_exporter: docker.io/kbudde/rabbitmq-exporter:v0.21.0 + prometheus_rabbitmq_exporter_helm_tests: docker.io/kolla/ubuntu-source-heat-engine:3.0.3 rabbitmq: docker.io/rabbitmq:3.7 dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.2.1 pull_policy: "IfNotPresent" @@ -36,8 +42,30 @@ pod: default: kubernetes.io/hostname replicas: server: 3 + prometheus_rabbitmq_exporter: 1 + lifecycle: + upgrades: + deployments: + revision_history: 3 + pod_replacement_strategy: RollingUpdate + rolling_update: + max_unavailable: 1 + max_surge: 3 + termination_grace_period: + prometheus_rabbitmq_exporter: + timeout: 30 + disruption_budget: + mariadb: + min_available: 0 resources: enabled: false + prometheus_rabbitmq_exporter: + limits: + memory: "1024Mi" + cpu: "2000m" + requests: + memory: "128Mi" + cpu: "500m" server: limits: memory: "128Mi" @@ -45,11 +73,24 @@ pod: requests: memory: "128Mi" cpu: "500m" + jobs: + tests: + limits: + memory: "1024Mi" + cpu: "2000m" + requests: + memory: "128Mi" + cpu: "100m" conf: enabled_plugins: - rabbitmq_management - rabbitmq_peer_discovery_k8s + prometheus_exporter: + capabilities: + - no_sort + log_level: info + skipverify: 1 rabbitmq: listeners: tcp: @@ -69,12 +110,48 @@ conf: dependencies: rabbitmq: jobs: null + prometheus_rabbitmq_exporter: + services: + - service: oslo_messaging + endpoint: internal + prometheus_rabbitmq_exporter_tests: + services: + - service: prometheus_rabbitmq_exporter + endpoint: internal + - service: monitoring + endpoint: internal + +monitoring: + prometheus: + enabled: false + rabbitmq_exporter: + scrape: true + +network: + prometheus_rabbitmq_exporter: + port: 9095 # typically overriden by environmental # values, but should include all endpoints # required by this chart endpoints: cluster_domain_suffix: cluster.local + monitoring: + name: prometheus + namespace: null + hosts: + default: prom-metrics + public: prometheus + host_fqdn_override: + default: null + path: + default: null + scheme: + default: 'http' + port: + api: + default: 9090 + public: 80 oslo_messaging: auth: erlang_cookie: openstack-cookie @@ -92,9 +169,27 @@ endpoints: default: 5672 http: default: 15672 + prometheus_rabbitmq_exporter: + namespace: null + hosts: + default: rabbitmq-exporter + host_fqdn_override: + default: null + path: + default: /metrics + scheme: + default: 'http' + port: + metrics: + default: 9095 manifests: configmap_bin: true configmap_etc: true + monitoring: + prometheus: + configmap_bin: true + deployment_exporter: true + service_exporter: true service: true statefulset: true