This is an automated email from the ASF dual-hosted git repository.
sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-helm-chart.git
The following commit(s) were added to refs/heads/master by this push:
new 025b263 Extend podmonitor and add relabels (#100)
025b263 is described below
commit 025b2632060f44b3012057227ce6625123290a7f
Author: Miecio <[email protected]>
AuthorDate: Sat Jan 30 18:24:21 2021 +0100
Extend podmonitor and add relabels (#100)
### Motivation
As I wanted to use
[streamnative/apache-pulsar-grafana-dashboard](https://github.com/streamnative/apache-pulsar-grafana-dashboard)
with this helm chart and own cluster wide Prometheus stack I decided that use
of PodMonitor CRD is a good way. Unfortunately prometheus config has some
metrics relabelings that are required by grafana dashboard. I decied to port
them directly to PodMonitor definition
### Modifications
* Added missing PodMonitor for autorecovery
* Port relabelings from `prometheus-configmap.yaml` to each PodMonitor
### Verifying this change
- [x] Make sure that the change passes the CI checks.
---
...odmonitor.yaml => autorecovery-podmonitor.yaml} | 24 ++++++++++++++++------
charts/pulsar/templates/bookkeeper-podmonitor.yaml | 12 +++++++++++
charts/pulsar/templates/broker-podmonitor.yaml | 12 +++++++++++
charts/pulsar/templates/proxy-podmonitor.yaml | 12 +++++++++++
charts/pulsar/templates/zookeeper-podmonitor.yaml | 12 +++++++++++
charts/pulsar/values.yaml | 6 ++++++
6 files changed, 72 insertions(+), 6 deletions(-)
diff --git a/charts/pulsar/templates/broker-podmonitor.yaml
b/charts/pulsar/templates/autorecovery-podmonitor.yaml
similarity index 60%
copy from charts/pulsar/templates/broker-podmonitor.yaml
copy to charts/pulsar/templates/autorecovery-podmonitor.yaml
index c3474b2..21d9b9f 100644
--- a/charts/pulsar/templates/broker-podmonitor.yaml
+++ b/charts/pulsar/templates/autorecovery-podmonitor.yaml
@@ -18,25 +18,37 @@
#
# deploy broker PodMonitor only when `$.Values.broker.podMonitor.enabled` is
true
-{{- if $.Values.broker.podMonitor.enabled }}
+{{- if $.Values.autorecovery.podMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
- name: {{ template "pulsar.name" . }}-broker
+ name: {{ template "pulsar.name" . }}-recovery
labels:
app: {{ template "pulsar.name" . }}
chart: {{ template "pulsar.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
- jobLabel: broker
+ jobLabel: recovery
podMetricsEndpoints:
- port: http
path: /metrics
scheme: http
- interval: {{ $.Values.broker.podMonitor.interval }}
- scrapeTimeout: {{ $.Values.broker.podMonitor.scrapeTimeout }}
+ interval: {{ $.Values.autorecovery.podMonitor.interval }}
+ scrapeTimeout: {{ $.Values.autorecovery.podMonitor.scrapeTimeout }}
+ relabelings:
+ - action: labelmap
+ regex: __meta_kubernetes_pod_label_(.+)
+ - sourceLabels: [__meta_kubernetes_namespace]
+ action: replace
+ targetLabel: kubernetes_namespace
+ - sourceLabels: [__meta_kubernetes_pod_label_component]
+ action: replace
+ targetLabel: job
+ - sourceLabels: [__meta_kubernetes_pod_name]
+ action: replace
+ targetLabel: kubernetes_pod_name
selector:
matchLabels:
- component: broker
+ component: {{ .Values.autorecovery.component }}
{{- end }}
\ No newline at end of file
diff --git a/charts/pulsar/templates/bookkeeper-podmonitor.yaml
b/charts/pulsar/templates/bookkeeper-podmonitor.yaml
index bec86fe..45a4aad 100644
--- a/charts/pulsar/templates/bookkeeper-podmonitor.yaml
+++ b/charts/pulsar/templates/bookkeeper-podmonitor.yaml
@@ -36,6 +36,18 @@ spec:
scheme: http
interval: {{ $.Values.bookkeeper.podMonitor.interval }}
scrapeTimeout: {{ $.Values.bookkeeper.podMonitor.scrapeTimeout }}
+ relabelings:
+ - action: labelmap
+ regex: __meta_kubernetes_pod_label_(.+)
+ - sourceLabels: [__meta_kubernetes_namespace]
+ action: replace
+ targetLabel: kubernetes_namespace
+ - sourceLabels: [__meta_kubernetes_pod_label_component]
+ action: replace
+ targetLabel: job
+ - sourceLabels: [__meta_kubernetes_pod_name]
+ action: replace
+ targetLabel: kubernetes_pod_name
selector:
matchLabels:
component: bookie
diff --git a/charts/pulsar/templates/broker-podmonitor.yaml
b/charts/pulsar/templates/broker-podmonitor.yaml
index c3474b2..515d218 100644
--- a/charts/pulsar/templates/broker-podmonitor.yaml
+++ b/charts/pulsar/templates/broker-podmonitor.yaml
@@ -36,6 +36,18 @@ spec:
scheme: http
interval: {{ $.Values.broker.podMonitor.interval }}
scrapeTimeout: {{ $.Values.broker.podMonitor.scrapeTimeout }}
+ relabelings:
+ - action: labelmap
+ regex: __meta_kubernetes_pod_label_(.+)
+ - sourceLabels: [__meta_kubernetes_namespace]
+ action: replace
+ targetLabel: kubernetes_namespace
+ - sourceLabels: [__meta_kubernetes_pod_label_component]
+ action: replace
+ targetLabel: job
+ - sourceLabels: [__meta_kubernetes_pod_name]
+ action: replace
+ targetLabel: kubernetes_pod_name
selector:
matchLabels:
component: broker
diff --git a/charts/pulsar/templates/proxy-podmonitor.yaml
b/charts/pulsar/templates/proxy-podmonitor.yaml
index bf925bf..18fd9ed 100644
--- a/charts/pulsar/templates/proxy-podmonitor.yaml
+++ b/charts/pulsar/templates/proxy-podmonitor.yaml
@@ -36,6 +36,18 @@ spec:
scheme: http
interval: {{ $.Values.proxy.podMonitor.interval }}
scrapeTimeout: {{ $.Values.proxy.podMonitor.scrapeTimeout }}
+ relabelings:
+ - action: labelmap
+ regex: __meta_kubernetes_pod_label_(.+)
+ - sourceLabels: [__meta_kubernetes_namespace]
+ action: replace
+ targetLabel: kubernetes_namespace
+ - sourceLabels: [__meta_kubernetes_pod_label_component]
+ action: replace
+ targetLabel: job
+ - sourceLabels: [__meta_kubernetes_pod_name]
+ action: replace
+ targetLabel: kubernetes_pod_name
selector:
matchLabels:
component: proxy
diff --git a/charts/pulsar/templates/zookeeper-podmonitor.yaml
b/charts/pulsar/templates/zookeeper-podmonitor.yaml
index 73b1267..0ca8853 100644
--- a/charts/pulsar/templates/zookeeper-podmonitor.yaml
+++ b/charts/pulsar/templates/zookeeper-podmonitor.yaml
@@ -36,6 +36,18 @@ spec:
scheme: http
interval: {{ $.Values.zookeeper.podMonitor.interval }}
scrapeTimeout: {{ $.Values.zookeeper.podMonitor.scrapeTimeout }}
+ relabelings:
+ - action: labelmap
+ regex: __meta_kubernetes_pod_label_(.+)
+ - sourceLabels: [__meta_kubernetes_namespace]
+ action: replace
+ targetLabel: kubernetes_namespace
+ - sourceLabels: [__meta_kubernetes_pod_label_component]
+ action: replace
+ targetLabel: job
+ - sourceLabels: [__meta_kubernetes_pod_name]
+ action: replace
+ targetLabel: kubernetes_pod_name
selector:
matchLabels:
component: zookeeper
diff --git a/charts/pulsar/values.yaml b/charts/pulsar/values.yaml
index 113ed9a..be05216 100644
--- a/charts/pulsar/values.yaml
+++ b/charts/pulsar/values.yaml
@@ -522,6 +522,12 @@ autorecovery:
# so the metrics are correctly rendered in grafana dashboard
component: recovery
replicaCount: 1
+ # If using Prometheus-Operator enable this PodMonitor to discover
autorecovery scrape targets
+ # # Prometheus-Operator does not add scrape targets based on k8s annotations
+ podMonitor:
+ enabled: false
+ interval: 10s
+ scrapeTimeout: 10s
# True includes annotation for statefulset that contains hash of
corresponding configmap, which will cause pods to restart on configmap change
restartPodsOnConfigMapChange: false
ports: