Skip to content

Commit 41e8cb5

Browse files
committed
Migrate from kube-prometheus-metrics to victoria-metrics-k8s-stack
1 parent 302db43 commit 41e8cb5

22 files changed

+418
-205
lines changed

.ci/chart_test.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ if [[ "$UPGRADE_FROM_VERSION" != "" ]]; then
6060
ALLOW_LOADBALANCERS="true"
6161
# install older version of pulsar chart
6262
PULSAR_CHART_VERSION="$UPGRADE_FROM_VERSION"
63-
ci::install_pulsar_chart install ${PULSAR_HOME}/.ci/values-common.yaml ${PULSAR_HOME}/${VALUES_FILE} "${extra_opts[@]}"
63+
64+
# Install Prometheus Operator CRDs using the upgrade script since kube-prometheus-stack is now disabled before the upgrade
65+
${PULSAR_HOME}/scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh
66+
67+
ci::install_pulsar_chart install ${PULSAR_HOME}/.ci/values-common.yaml ${PULSAR_HOME}/${VALUES_FILE} --set kube-prometheus-stack.enabled=false "${extra_opts[@]}"
6468
install_type="upgrade"
6569
echo "Wait 10 seconds"
6670
sleep 10
@@ -72,9 +76,9 @@ if [[ "$UPGRADE_FROM_VERSION" != "" ]]; then
7276
ci::test_pulsar_producer_consumer "produce"
7377
test_action="consume"
7478

75-
if [[ "$(ci::helm_values_for_deployment | yq .kube-prometheus-stack.enabled)" == "true" ]]; then
76-
echo "Upgrade Prometheus Operator CRDs before upgrading the deployment"
77-
${PULSAR_HOME}/scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh
79+
if [[ "$(ci::helm_values_for_deployment | yq .victoria-metrics-k8s-stack.enabled)" == "true" ]]; then
80+
echo "Upgrade Victoria Metrics Operator CRDs before upgrading the deployment"
81+
${PULSAR_HOME}/scripts/victoria-metrics-k8s-stack/upgrade_vm_operator_crds.sh
7882
fi
7983
fi
8084

.ci/clusters/values-prometheus-grafana.yaml .ci/clusters/values-victoria-metrics-grafana.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
# under the License.
1818
#
1919

20-
kube-prometheus-stack:
20+
victoria-metrics-k8s-stack:
2121
enabled: true
22-
prometheusOperator:
22+
victoria-metrics-operator:
2323
enabled: true
24-
prometheus:
24+
vmsingle:
25+
enabled: true
26+
vmagent:
2527
enabled: true
2628
grafana:
2729
enabled: true
2830
adminPassword: pulsar-ci-admin
29-
alertmanager:
30-
enabled: false
3131
prometheus-node-exporter:
3232
enabled: true
3333

.ci/helm.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function ci::install_cert_manager() {
8484
function ci::helm_repo_add() {
8585
echo "Adding the helm repo ..."
8686
${HELM} repo add prometheus-community https://prometheus-community.github.io/helm-charts
87+
${HELM} repo add vm https://victoriametrics.github.io/helm-charts/
8788
${HELM} repo update
8889
echo "Successfully added the helm repo."
8990
}
@@ -117,7 +118,7 @@ function ci::install_pulsar_chart() {
117118
local extra_opts=()
118119
local values_next=false
119120
for arg in "$@"; do
120-
if [[ "$arg" == "--values" ]]; then
121+
if [[ "$arg" == "--values" || "$arg" == "--set" ]]; then
121122
extra_values+=("$arg")
122123
values_next=true
123124
elif [[ "$values_next" == true ]]; then

.ci/kustomization.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ helmCharts:
2525
- name: pulsar
2626
releaseName: pulsar
2727
valuesInline:
28-
kube-prometheus-stack:
28+
victoria-metrics-k8s-stack:
2929
enabled: false
3030
components:
3131
pulsar_manager: true

.ci/values-common.yaml

+24-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,35 @@
1717
# under the License.
1818
#
1919

20-
kube-prometheus-stack:
20+
victoria-metrics-k8s-stack:
2121
enabled: false
22-
prometheusOperator:
22+
victoria-metrics-operator:
2323
enabled: false
24-
grafana:
24+
vmsingle:
25+
enabled: false
26+
vmagent:
27+
enabled: false
28+
vmalert:
2529
enabled: false
2630
alertmanager:
2731
enabled: false
28-
prometheus:
32+
grafana:
33+
enabled: false
34+
prometheus-node-exporter:
35+
enabled: false
36+
kube-state-metrics:
37+
enabled: false
38+
kubelet:
39+
enabled: false
40+
kubeApiServer:
41+
enabled: false
42+
kubeControllerManager:
43+
enabled: false
44+
coreDns:
45+
enabled: false
46+
kubeEtcd:
47+
enabled: false
48+
kubeScheduler:
2949
enabled: false
3050

3151
# disabled AntiAffinity

.github/workflows/pulsar-helm-chart-ci.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
else
152152
echo ""
153153
fi
154-
helm template charts/pulsar --set kube-prometheus-stack.enabled=false --set components.pulsar_manager=true --kube-version $kube_version "$@" | \
154+
helm template charts/pulsar --set victoria-metrics-k8s-stack.enabled=false --set components.pulsar_manager=true --kube-version $kube_version "$@" | \
155155
kubeconform -schema-location default -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' -strict -kubernetes-version $kube_version -summary
156156
}
157157
set -o pipefail
@@ -242,9 +242,9 @@ jobs:
242242
version: "1.25.16"
243243
kind_image_tag: v1.25.16@sha256:6110314339b3b44d10da7d27881849a87e092124afab5956f2e10ecdb463b025
244244
testScenario:
245-
name: "Upgrade kube-prometheus-stack for previous LTS"
246-
values_file: .ci/clusters/values-prometheus-grafana.yaml --values .ci/clusters/values-pulsar-previous-lts.yaml
247-
shortname: prometheus-grafana
245+
name: "Upgrade victoria-metrics-k8s-stack for previous LTS"
246+
values_file: .ci/clusters/values-victoria-metrics-grafana.yaml --values .ci/clusters/values-pulsar-previous-lts.yaml
247+
shortname: victoria-metrics-grafana
248248
type: upgrade
249249
upgradeFromVersion: 3.2.0
250250
- k8sVersion:

README.md

+32-64
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ This Helm Chart includes all the components of Apache Pulsar for a complete expe
141141
- [x] Management & monitoring components:
142142
- [x] Pulsar Manager
143143
- [x] Optional PodMonitors for each component (enabled by default)
144-
- [x] [Kube-Prometheus-Stack](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack) (as of 3.0.0)
144+
- [x] [victoria-metrics-k8s-stack](hhttps://github.com/VictoriaMetrics/helm-charts/tree/master/charts/victoria-metrics-k8s-stack) (as of 4.0.0)
145145

146146
It includes support for:
147147

@@ -276,25 +276,26 @@ You can also checkout out the example values file for different deployments.
276276
- [Deploy a Pulsar cluster with JWT authentication using symmetric key](examples/values-jwt-symmetric.yaml)
277277
- [Deploy a Pulsar cluster with JWT authentication using asymmetric key](examples/values-jwt-asymmetric.yaml)
278278

279-
## Disabling Kube-Prometheus-Stack CRDs
279+
## Disabling victoria-metrics-k8s-stack components
280280

281-
In order to disable the kube-prometheus-stack fully, it is necessary to add the following to your `values.yaml`:
281+
In order to disable the victoria-metrics-k8s-stack, you can add the following to your `values.yaml`.
282+
Victoria Metrics components can also be disabled and enabled individually if you only need specific monitoring features.
283+
Please refer to the default [`values.yaml`](charts/pulsar/values.yaml).
282284

283285
```yaml
284-
kube-prometheus-stack:
286+
victoria-metrics-k8s-stack:
285287
enabled: false
286-
prometheusOperator:
288+
victoria-metrics-operator:
287289
enabled: false
288-
grafana:
290+
kube-state-metrics:
289291
enabled: false
290-
alertmanager:
292+
prometheus-node-exporter:
291293
enabled: false
292-
prometheus:
294+
grafana:
293295
enabled: false
294296
```
295297

296-
Otherwise, the helm chart installation will attempt to install the CRDs for the kube-prometheus-stack. Additionally,
297-
you'll need to disable each of the component's `PodMonitors`. This is shown in some [examples](./examples) and is
298+
Additionally, you'll need to set each component's `podMonitor` property to `false`. This is shown in some [examples](./examples) and is
298299
verified in some [tests](./.ci/clusters).
299300

300301
## Pulsar Manager
@@ -319,12 +320,12 @@ kubectl get secret -l component=pulsar-manager -o=jsonpath="{.items[0].data.UI_P
319320
320321
## Grafana Dashboards
321322
322-
The Apache Pulsar Helm Chart uses the `kube-prometheus-stack` Helm Chart to deploy Grafana.
323+
The Apache Pulsar Helm Chart uses the `victoria-metrics-k8s-stack` Helm Chart to deploy Grafana.
323324
324-
There are several ways to configure Grafana dashboards. The default `values.yaml` comes with examples of Pulsar dashboards which get downloaded from the Apache-2.0 licensed [streamnative/apache-pulsar-grafana-dashboard OSS project](https://github.com/streamnative/apache-pulsar-grafana-dashboard) by URL.
325+
There are several ways to configure Grafana dashboards. The default [`values.yaml`](charts/pulsar/values.yaml) comes with examples of Pulsar dashboards which get downloaded from the Apache-2.0 licensed [lhotari/pulsar-grafana-dashboards OSS project](https://github.com/lhotari/pulsar-grafana-dashboards) by URL.
325326
326-
Dashboards can be configured in `values.yaml` or by adding `ConfigMap` items with the label `grafana_dashboard: "1"`.
327-
In `values.yaml`, it's possible to include dashboards by URL or by grafana.com dashboard id (`gnetId` and `revision`).
327+
Dashboards can be configured in [`values.yaml`](charts/pulsar/values.yaml) or by adding `ConfigMap` items with the label `grafana_dashboard: "1"`.
328+
In [`values.yaml`](charts/pulsar/values.yaml), it's possible to include dashboards by URL or by grafana.com dashboard id (`gnetId` and `revision`).
328329
Please see the [Grafana Helm chart documentation for importing dashboards](https://github.com/grafana/helm-charts/blob/main/charts/grafana/README.md#import-dashboards).
329330
330331
You can connect to Grafana by forwarding port 3000
@@ -354,6 +355,8 @@ updates should be done using `helm upgrade`.
354355
```bash
355356
helm repo add apachepulsar https://pulsar.apache.org/charts
356357
helm repo update
358+
# If you are using the provided victoria-metrics-k8s-stack for monitoring, this installs or upgrades the required CRDs
359+
./scripts/victoria-metrics-k8s-stack/upgrade_vm_operator_crds.sh
357360
# get the existing values.yaml used for the most recent deployment
358361
helm get values -n <namespace> <pulsar-release-name> > values.yaml
359362
# upgrade the deployment
@@ -362,65 +365,29 @@ helm upgrade -n <namespace> -f values.yaml <pulsar-release-name> apachepulsar/pu
362365

363366
For more detailed information, see our [Upgrading](http://pulsar.apache.org/docs/helm-upgrade/) guide.
364367

365-
## Upgrading from Helm Chart version 3.x.x to 4.0.0 version and above
368+
## Upgrading from Helm Chart versions before 4.0.0 to 4.0.0 version and above
366369

367370
### Pulsar Proxy service's default type has been changed from `LoadBalancer` to `ClusterIP`
368371

369372
Please check the section "External Access Recommendations" for guidance and also check the security advisory section.
370373
You will need to configure keys under `proxy.service` in your `values.yaml` to preserve existing functionality since the default has been changed.
371374

372-
### kube-prometheus-stack upgrade
375+
### kube-prometheus-stack replaced with victoria-metrics-k8s-stack
373376

374-
The kube-prometheus-stack version has been upgraded to 69.x.x in Pulsar Helm Chart version 4.0.0 .
375-
Before running "helm upgrade", you should first upgrade the Prometheus Operator CRDs as [instructed
376-
in kube-prometheus-stack upgrade notes](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#from-68x-to-69x).
377+
The kube-prometheus-stack version has been removed in Pulsar Helm Chart version 4.0.0 due to
378+
Prometheus incompatibility with Pulsar metrics since Pulsar 2.11.0 . Pulsar exposes metrics in a format that is partially OpenMetrics 1.0.0 text format,
379+
but isn't fully compatible. Prometheus doesn't provide proper support for OpenMetrics 1.0.0 text format, even in Prometheus version 3.2.1 where it was
380+
extensively tested before switching to Victoria Metrics in Pulsar Helm chart version 4.0.0 . Victoria Metrics is Apache 2.0 Licensed OSS and it's fully
381+
compatible with Prometheus.
377382

378-
There's a script to run the required commands:
383+
Before upgrading to Pulsar Helm Chart version 4.0.0, it is recommended to disable kube-prometheus-stack in the original Helm chart version that
384+
is used:
379385

380386
```shell
381-
./scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh 0.80.0
382-
```
383-
384-
After, this you can proceed with `helm upgrade`.
385-
386-
## Upgrading from Helm Chart version 3.0.0-3.6.0 to 3.7.0 version and above
387-
388-
The kube-prometheus-stack version has been upgraded to 65.x.x in Pulsar Helm Chart version 3.7.0 .
389-
Before running "helm upgrade", you should first upgrade the Prometheus Operator CRDs as [instructed
390-
in kube-prometheus-stack upgrade notes](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#from-64x-to-65x).
391-
392-
There's a script to run the required commands:
393-
394-
```shell
395-
./scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh 0.77.1
396-
```
397-
398-
After, this you can proceed with `helm upgrade`.
399-
400-
## Upgrading from Helm Chart version 3.0.0-3.4.x to 3.5.0 version and above
401-
402-
The kube-prometheus-stack version has been upgraded to 59.x.x in Pulsar Helm Chart version 3.5.0 .
403-
Before running "helm upgrade", you should first upgrade the Prometheus Operator CRDs as [instructed
404-
in kube-prometheus-stack upgrade notes](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#from-58x-to-59x).
405-
406-
There's a script to run the required commands:
407-
408-
```shell
409-
./scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh 0.74.0
410-
```
411-
412-
After, this you can proceed with `helm upgrade`.
413-
414-
## Upgrading from Helm Chart version 3.0.0-3.2.x to 3.3.0 version and above
415-
416-
The kube-prometheus-stack version has been upgraded to 56.x.x in Pulsar Helm Chart version 3.3.0 .
417-
Before running "helm upgrade", you should first upgrade the Prometheus Operator CRDs as [instructed
418-
in kube-prometheus-stack upgrade notes](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#from-55x-to-56x).
419-
420-
There's a script to run the required commands:
421-
422-
```shell
423-
./scripts/kube-prometheus-stack/upgrade_prometheus_operator_crds.sh 0.71.0
387+
# get the existing values.yaml used for the most recent deployment
388+
helm get values -n <namespace> <pulsar-release-name> > values.yaml
389+
# disable kube-prometheus-stack in the currently used version before upgrading to Pulsar Helm chart 4.0.0
390+
helm upgrade -n <namespace> -f values.yaml --version <your-current-chart-version> --set kube-prometheus-stack.enabled=false <pulsar-release-name> apachepulsar/pulsar
424391
```
425392

426393
After, this you can proceed with `helm upgrade`.
@@ -430,7 +397,7 @@ After, this you can proceed with `helm upgrade`.
430397
The 2.10.0+ Apache Pulsar docker image is a non-root container, by default. That complicates an upgrade to 2.10.0
431398
because the existing files are owned by the root user but are not writable by the root group. In order to leverage this
432399
new security feature, the Bookkeeper and Zookeeper StatefulSet [securityContexts](https://kubernetes.io/docs/tasks/configure-pod-container/security-context)
433-
are configurable in the `values.yaml`. They default to:
400+
are configurable in the [`values.yaml`](charts/pulsar/values.yaml). They default to:
434401

435402
```yaml
436403
securityContext:
@@ -478,6 +445,7 @@ Caused by: org.rocksdb.RocksDBException: while open a file for lock: /pulsar/dat
478445
### Recovering from `helm upgrade` error "unable to build kubernetes objects from current release manifest"
479446

480447
Example of the error message:
448+
481449
```bash
482450
Error: UPGRADE FAILED: unable to build kubernetes objects from current release manifest:
483451
[resource mapping not found for name: "pulsar-bookie" namespace: "pulsar" from "":

charts/pulsar/Chart.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ maintainers:
3232
- name: The Apache Pulsar Team
3333
3434
dependencies:
35-
- name: kube-prometheus-stack
36-
version: 67.x.x
37-
repository: https://prometheus-community.github.io/helm-charts
38-
condition: kube-prometheus-stack.enabled
35+
- name: victoria-metrics-k8s-stack
36+
version: 0.38.x
37+
repository: https://victoriametrics.github.io/helm-charts/
38+
condition: victoria-metrics-k8s-stack.enabled

charts/pulsar/templates/NOTES.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Watching events to view progress of deployment:
102102
kubectl get -n {{ .Values.namespace | default .Release.Namespace }} events -o wide --watch
103103

104104
Watching state of deployed Kubernetes objects, updated every 2 seconds:
105-
watch kubectl get -n {{ .Values.namespace | default .Release.Namespace }} all
105+
watch kubectl get -n {{ .Values.namespace | default .Release.Namespace }} all
106106

107107
{{- if .Values.components.proxy }}
108108

charts/pulsar/templates/autorecovery-podmonitor.yaml

+17-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@
1919

2020
# deploy broker PodMonitor only when `$.Values.broker.podMonitor.enabled` is true
2121
{{- if $.Values.autorecovery.podMonitor.enabled }}
22+
{{- if index .Values "victoria-metrics-k8s-stack" "enabled" }}
23+
apiVersion: operator.victoriametrics.com/v1beta1
24+
kind: VMPodScrape
25+
{{- else }}
2226
apiVersion: monitoring.coreos.com/v1
2327
kind: PodMonitor
28+
{{- end }}
2429
metadata:
2530
name: {{ template "pulsar.name" . }}-recovery
2631
labels:
@@ -30,14 +35,17 @@ metadata:
3035
heritage: {{ .Release.Service }}
3136
spec:
3237
jobLabel: recovery
33-
fallbackScrapeProtocol: PrometheusText0.0.4
3438
podMetricsEndpoints:
3539
- port: http
3640
path: /metrics
3741
scheme: http
3842
interval: {{ $.Values.autorecovery.podMonitor.interval }}
3943
scrapeTimeout: {{ $.Values.autorecovery.podMonitor.scrapeTimeout }}
44+
{{- if index .Values "victoria-metrics-k8s-stack" "enabled" }}
45+
relabelConfigs:
46+
{{- else }}
4047
relabelings:
48+
{{- end }}
4149
- action: labelmap
4250
regex: __meta_kubernetes_pod_label_(.+)
4351
- sourceLabels: [__meta_kubernetes_namespace]
@@ -49,9 +57,14 @@ spec:
4957
- sourceLabels: [__meta_kubernetes_pod_name]
5058
action: replace
5159
targetLabel: kubernetes_pod_name
52-
{{- if $.Values.autorecovery.podMonitor.metricRelabelings }}
53-
metricRelabelings: {{ toYaml $.Values.autorecovery.podMonitor.metricRelabelings | nindent 8 }}
54-
{{- end }}
60+
{{- if index .Values "victoria-metrics-k8s-stack" "enabled" }}
61+
metricRelabelConfigs:
62+
{{- else }}
63+
metricRelabelings:
64+
{{- end }}
65+
{{- if $.Values.autorecovery.podMonitor.metricRelabelings }}
66+
{{- toYaml $.Values.autorecovery.podMonitor.metricRelabelings | nindent 8 }}
67+
{{- end }}
5568
selector:
5669
matchLabels:
5770
{{- include "pulsar.matchLabels" . | nindent 6 }}

0 commit comments

Comments
 (0)