From 9522acbfd161903590a03c032803b873a95775ab Mon Sep 17 00:00:00 2001 From: Gabriele Santomaggio Date: Mon, 28 Oct 2019 23:10:43 +0100 Subject: [PATCH] [stable/rabbitmq-ha]Endpoint for RabbitMQ Prometheus native port (#18106) * Endpoint for RabbitMQ Prometheus native port The features add a new Endpoint for Prometheus, by default is 15692 Important for use the feature `kubernetes_sd_configs: - role: pod` Complete the PR: https://github.com/helm/charts/pull/17925 Signed-off-by: Gabriele Santomaggio * Added service monitor for the native prometheus rabbitmq plugin Signed-off-by: Mihai Anei * Increase Chart version as 1.34.1 is already released Signed-off-by: Mihai Anei * Removed metrics port from service-discovery Signed-off-by: Mihai Anei * Cleaned duplication in servicemonitor and added the new values in Readme Signed-off-by: Mihai Anei * Upgraded RabbitMQ to 3.8.0-alpine Signed-off-by: Mihai Anei * Removed hardcoded metrics port value in StatefulSet Signed-off-by: Mihai Anei * Fixed trailing spaces for linting checks Signed-off-by: Mihai Anei * Simplified ServiceMonitor endpoints Signed-off-by: Mihai Anei * Fixed appVersion in Chart and Readme Signed-off-by: Mihai Anei * Added ci test values for prometheus exporter and native plugin Signed-off-by: Mihai Anei * Disable prometheus.operator in ci test values Signed-off-by: Mihai Anei --- stable/rabbitmq-ha/Chart.yaml | 4 ++-- stable/rabbitmq-ha/README.md | 8 ++++++-- .../ci/prometheus-exporter-values.yaml | 8 ++++++++ .../ci/prometheus-plugin-values.yaml | 8 ++++++++ stable/rabbitmq-ha/templates/_helpers.tpl | 2 +- stable/rabbitmq-ha/templates/configmap.yaml | 2 ++ stable/rabbitmq-ha/templates/service.yaml | 9 +++++++++ .../rabbitmq-ha/templates/servicemonitor.yaml | 13 +++++++++---- stable/rabbitmq-ha/templates/statefulset.yaml | 5 +++++ stable/rabbitmq-ha/values.yaml | 18 +++++++++++++++--- 10 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 stable/rabbitmq-ha/ci/prometheus-exporter-values.yaml create mode 100644 stable/rabbitmq-ha/ci/prometheus-plugin-values.yaml diff --git a/stable/rabbitmq-ha/Chart.yaml b/stable/rabbitmq-ha/Chart.yaml index 0c380328e6..ad900145d6 100644 --- a/stable/rabbitmq-ha/Chart.yaml +++ b/stable/rabbitmq-ha/Chart.yaml @@ -1,7 +1,7 @@ name: rabbitmq-ha apiVersion: v1 -appVersion: 3.7.19 -version: 1.34.1 +appVersion: 3.8.0 +version: 1.35.0 description: Highly available RabbitMQ cluster, the open source message broker software that implements the Advanced Message Queuing Protocol (AMQP). keywords: diff --git a/stable/rabbitmq-ha/README.md b/stable/rabbitmq-ha/README.md index ad1802d449..e73a632d9f 100644 --- a/stable/rabbitmq-ha/README.md +++ b/stable/rabbitmq-ha/README.md @@ -86,7 +86,7 @@ and their default values. | `forceBoot` | [Force](https://www.rabbitmq.com/rabbitmqctl.8.html#force_boot) the cluster to start even if it was shutdown in an unexpected order, preferring availability over integrity | `false` | | `image.pullPolicy` | Image pull policy | `IfNotPresent` | | `image.repository` | RabbitMQ container image repository | `rabbitmq` | -| `image.tag` | RabbitMQ container image tag | `3.7.19-alpine` | +| `image.tag` | RabbitMQ container image tag | `3.8.0-alpine` | | `image.pullSecrets` | Specify docker-registry secret names as an array | `[]` | | `managementPassword` | Management user password. | _random 24 character long alphanumeric string_ | | `managementUsername` | Management user with minimal permissions used for health checks | `management` | @@ -142,7 +142,11 @@ and their default values. | `rabbitmqWebMQTTPlugin.enabled` | Enable MQTT over websocket plugin | `false` | | `rabbitmqWebSTOMPPlugin.config` | STOMP over websocket configuration | `` | | `rabbitmqWebSTOMPPlugin.enabled` | Enable STOMP over websocket plugin | `false` | -| `rabbitmqPrometheusPlugin.enabled` | Enable native RabbitMQ prometheus plugin. (Available in RabbitMQ 3.8) | `false` | +| `rabbitmqPrometheusPlugin.enabled` | Enable native RabbitMQ prometheus plugin. (Available in RabbitMQ 3.8) | `false` | +| `rabbitmqPrometheusPlugin.nodePort` | Exposes the native prometheus metrics port on the given NodePort | `null` | +| `rabbitmqPrometheusPlugin.port` | The port RabbitMQ prometheus plugin will use | `15692` | +| `rabbitmqPrometheusPlugin.path` | The path RabbitMQ prometheus plugin will use | `/metrics` | +| `rabbitmqPrometheusPlugin.config` | RabbitMQ prometheus plugin aditional configuration | `` | | `rbac.create` | If true, create & use RBAC resources | `true` | | `replicaCount` | Number of replica | `3` | | `resources` | CPU/Memory resource requests/limits | `{}` | diff --git a/stable/rabbitmq-ha/ci/prometheus-exporter-values.yaml b/stable/rabbitmq-ha/ci/prometheus-exporter-values.yaml new file mode 100644 index 0000000000..f89839b97e --- /dev/null +++ b/stable/rabbitmq-ha/ci/prometheus-exporter-values.yaml @@ -0,0 +1,8 @@ +# Testing Prometheus exporter + +prometheus: + exporter: + enabled: true + + operator: + enabled: false diff --git a/stable/rabbitmq-ha/ci/prometheus-plugin-values.yaml b/stable/rabbitmq-ha/ci/prometheus-plugin-values.yaml new file mode 100644 index 0000000000..a99c3f63a0 --- /dev/null +++ b/stable/rabbitmq-ha/ci/prometheus-plugin-values.yaml @@ -0,0 +1,8 @@ +# Testing native Prometheus plugin + +rabbitmqPrometheusPlugin: + enabled: true + +prometheus: + operator: + enabled: false diff --git a/stable/rabbitmq-ha/templates/_helpers.tpl b/stable/rabbitmq-ha/templates/_helpers.tpl index f0b395f86a..ab2f6c4007 100644 --- a/stable/rabbitmq-ha/templates/_helpers.tpl +++ b/stable/rabbitmq-ha/templates/_helpers.tpl @@ -113,4 +113,4 @@ users, virtual hosts, permissions and parameters) to load by the management plug {{ .Values.definitions.bindings| indent 4 }} ] } -{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/stable/rabbitmq-ha/templates/configmap.yaml b/stable/rabbitmq-ha/templates/configmap.yaml index 72b494cd2b..fa3e8845c4 100644 --- a/stable/rabbitmq-ha/templates/configmap.yaml +++ b/stable/rabbitmq-ha/templates/configmap.yaml @@ -115,6 +115,8 @@ data: ## Prometheus Plugin {{- if .Values.rabbitmqPrometheusPlugin.enabled }} {{ .Values.rabbitmqPrometheusPlugin.config | indent 4 }} + prometheus.path = {{ .Values.rabbitmqPrometheusPlugin.path }} + prometheus.tcp.port = {{ .Values.rabbitmqPrometheusPlugin.port }} {{- end }} ## AMQPS support diff --git a/stable/rabbitmq-ha/templates/service.yaml b/stable/rabbitmq-ha/templates/service.yaml index af8500db6b..5ab4d873d0 100644 --- a/stable/rabbitmq-ha/templates/service.yaml +++ b/stable/rabbitmq-ha/templates/service.yaml @@ -96,6 +96,15 @@ spec: port: {{ .Values.prometheus.exporter.port }} targetPort: exporter {{ end }} + {{- if .Values.rabbitmqPrometheusPlugin.enabled }} + - name: metrics + protocol: TCP + {{- if eq .Values.service.type "NodePort" "LoadBalancer" }} + nodePort: {{ .Values.rabbitmqPrometheusPlugin.nodePort }} + {{- end }} + port: {{ .Values.rabbitmqPrometheusPlugin.port }} + targetPort: metrics + {{- end }} selector: app: {{ template "rabbitmq-ha.name" . }} release: {{ .Release.Name }} diff --git a/stable/rabbitmq-ha/templates/servicemonitor.yaml b/stable/rabbitmq-ha/templates/servicemonitor.yaml index 967e578cd1..dad8430a6d 100644 --- a/stable/rabbitmq-ha/templates/servicemonitor.yaml +++ b/stable/rabbitmq-ha/templates/servicemonitor.yaml @@ -1,4 +1,4 @@ -{{ if and .Values.prometheus.exporter.enabled .Values.prometheus.operator.enabled }} +{{ if and (or .Values.prometheus.exporter.enabled .Values.rabbitmqPrometheusPlugin.enabled) .Values.prometheus.operator.enabled }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: @@ -14,8 +14,13 @@ spec: app: {{ template "rabbitmq-ha.name" . }} release: {{ .Release.Name }} endpoints: - - port: exporter - interval: {{ .Values.prometheus.operator.serviceMonitor.interval }} + - interval: {{ .Values.prometheus.operator.serviceMonitor.interval }} + {{- if .Values.rabbitmqPrometheusPlugin.enabled }} + port: metrics + path: {{ .Values.rabbitmqPrometheusPlugin.path }} + {{- else }} + port: exporter + {{- end }} namespaceSelector: any: true -{{ end }} +{{- end }} \ No newline at end of file diff --git a/stable/rabbitmq-ha/templates/statefulset.yaml b/stable/rabbitmq-ha/templates/statefulset.yaml index 02b5944a16..b965ad08c2 100644 --- a/stable/rabbitmq-ha/templates/statefulset.yaml +++ b/stable/rabbitmq-ha/templates/statefulset.yaml @@ -137,6 +137,11 @@ spec: protocol: TCP containerPort: 5671 {{- end }} + {{- if .Values.rabbitmqPrometheusPlugin.enabled }} + - name: metrics + protocol: TCP + containerPort: {{ .Values.rabbitmqPrometheusPlugin.port }} + {{- end }} livenessProbe: {{- toYaml .Values.livenessProbe | trim | nindent 12 }} readinessProbe: diff --git a/stable/rabbitmq-ha/values.yaml b/stable/rabbitmq-ha/values.yaml index 368ce21e9f..85614c0feb 100644 --- a/stable/rabbitmq-ha/values.yaml +++ b/stable/rabbitmq-ha/values.yaml @@ -257,10 +257,22 @@ rabbitmqWebSTOMPPlugin: ## Ref: https://www.rabbitmq.com/prometheus.html rabbitmqPrometheusPlugin: enabled: false + + ## NodePort + nodePort: null + + ## metrics port, overrides configuration: + ## prometheus.tcp.port + port: 15692 + + ## metrics path, overrides configuration: + ## prometheus.path + path: /metrics + ## Prometheus configuration: + ## https://github.com/rabbitmq/rabbitmq-prometheus config: | - # prometheus.path = /metrics - # prometheus.tcp.port = 15692 + ## prometheus.path and prometheus.tcp.port can be set above ## AMQPS support ## Ref: http://www.rabbitmq.com/ssl.html @@ -284,7 +296,7 @@ replicaCount: 3 image: repository: rabbitmq - tag: 3.7.19-alpine + tag: 3.8.0-alpine pullPolicy: IfNotPresent ## Optionally specify an array of imagePullSecrets. ## Secrets must be manually created in the namespace.