From 109b9a026ec1d00f6ec5997e97b9e32f2f33e789 Mon Sep 17 00:00:00 2001 From: Xavier Bai Date: Mon, 24 Jun 2024 11:36:53 +0800 Subject: [PATCH] [AMORO-2932] fix prometheus exporter issues in helm chart (#2933) * [WAP] fix prometheus exporter issues in helm chart * fix --------- Co-authored-by: ZhouJinsong --- charts/amoro/templates/_pod.tpl | 17 +++++++++ charts/amoro/templates/amoro-configmap.yaml | 8 ++--- charts/amoro/templates/amoro-deployment.yaml | 7 +--- charts/amoro/tests/amoro-configmap_test.yaml | 9 ++--- charts/amoro/values.yaml | 37 ++++++++------------ 5 files changed, 40 insertions(+), 38 deletions(-) diff --git a/charts/amoro/templates/_pod.tpl b/charts/amoro/templates/_pod.tpl index b65cbcde12..7fe844be31 100644 --- a/charts/amoro/templates/_pod.tpl +++ b/charts/amoro/templates/_pod.tpl @@ -108,3 +108,20 @@ spark distribution package will be installed to here*/ -}} {{- end -}} {{- end -}} {{- /* define "amoro.pod.volumes" end */ -}} + +{{- /* define ports for each pod */ -}} +{{- define "amoro.pod.container.ports" -}} +- name: rest + containerPort: {{ .Values.server.rest.port }} +- name: table + containerPort: {{ .Values.server.table.port }} +- name: optimizing + containerPort: {{ .Values.server.optimizing.port }} +{{- if .Values.plugin.metricReporters }} +{{- if .Values.plugin.metricReporters.prometheusExporter.enabled }} +- name: prometheus + containerPort: {{ .Values.plugin.metricReporters.prometheusExporter.port }} +{{- end -}} +{{- end -}} +{{- end -}} +{{- /* define amoro.pod.container.ports end */ -}} \ No newline at end of file diff --git a/charts/amoro/templates/amoro-configmap.yaml b/charts/amoro/templates/amoro-configmap.yaml index 7330b980a3..1ffb9710d1 100644 --- a/charts/amoro/templates/amoro-configmap.yaml +++ b/charts/amoro/templates/amoro-configmap.yaml @@ -30,12 +30,10 @@ data: ## Helm chart provided metric reporters configurations metric-reporters.yaml: | metric-reporters: - {{- range . }} - - name: {{ .name }} - enabled: {{ .enabled }} + - name: {{ .prometheusExporter.name }} + enabled: {{ .prometheusExporter.enabled }} properties: - {{ .properties | toYaml | nindent 10 | trim}} - {{- end }} + {{ .prometheusExporter.properties | toYaml | nindent 10 | trim }} {{- end }} ## Helm chart provided Amoro configurations config.yaml: | diff --git a/charts/amoro/templates/amoro-deployment.yaml b/charts/amoro/templates/amoro-deployment.yaml index ee46076ec7..da9397b719 100644 --- a/charts/amoro/templates/amoro-deployment.yaml +++ b/charts/amoro/templates/amoro-deployment.yaml @@ -79,12 +79,7 @@ spec: {{/* TODO If Support Replica can be use more than 1 */}} {{- tpl (toYaml .) $ | nindent 12 }} {{- end }} ports: - - name: rest - containerPort: {{ .Values.server.rest.port }} - - name: table - containerPort: {{ .Values.server.table.port }} - - name: optimizing - containerPort: {{ .Values.server.optimizing.port }} + {{- include "amoro.pod.container.ports" . | nindent 12 }} {{- if .Values.livenessProbe.enabled }} livenessProbe: httpGet: diff --git a/charts/amoro/tests/amoro-configmap_test.yaml b/charts/amoro/tests/amoro-configmap_test.yaml index d4fb8c2653..73a5fe97ce 100644 --- a/charts/amoro/tests/amoro-configmap_test.yaml +++ b/charts/amoro/tests/amoro-configmap_test.yaml @@ -113,13 +113,14 @@ tests: set: plugin: metricReporters: - - name: prometheus-exporter + prometheusExporter: + name: prometheus-exporter enabled: true - properties: - port: 7001 + port: 7001 + properties: ~ asserts: - matchRegex: path: data["metric-reporters.yaml"] pattern: | - - name: prometheus-exporter \ No newline at end of file + name: prometheus-exporter \ No newline at end of file diff --git a/charts/amoro/values.yaml b/charts/amoro/values.yaml index ae085dbeed..c906887b8b 100644 --- a/charts/amoro/values.yaml +++ b/charts/amoro/values.yaml @@ -274,29 +274,20 @@ plugin: ## metricReporters: ~ ## e.g: -## metricReporters: -## ## @param Configure Prometheus exporter -## ## -## - name: prometheus-exporter -## ## @param Enable or disable the Prometheus exporter -## ## -## enabled: true -## ## @param Properties for the Prometheus exporter -## ## -## properties: -## port: 7001 -## ## @param Kubernetes service configuration for the Prometheus exporter -## ## ref: https://kubernetes.io/docs/reference/kubernetes-api/service-resources/service-v1/ -## ## -## service: -## type: ClusterIP -## port: "7001" -## nodePort: ~ -## annotations: { -## "prometheus.io/scrape": "true", -## "prometheus.io/path": "/metrics", -## "prometheus.io/port": "7001" -## } +# metricReporters: +# ## @param Configure Prometheus exporter +# ## +# prometheusExporter: +# name: prometheus-exporter +# ## @param Enable or disable the Prometheus exporter +# ## +# enabled: true +# ## @param Prometheus port +# ## +# port: 7001 +# ## @param Properties for the Prometheus exporter +# ## +# properties: ~ ## Configure the ingress resource that allows you to access the ## Amoro installation. Set up the URL