Skip to content

Commit

Permalink
[AMORO-2898] Support metrics related settings for helm charts (#2907)
Browse files Browse the repository at this point in the history
* add helm metric reporters

* add helm metric reporters test

---------

Co-authored-by: ZhouJinsong <[email protected]>
  • Loading branch information
jiamin13579 and zhoujinsong authored Jun 12, 2024
1 parent 0c51628 commit 6949253
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 2 deletions.
7 changes: 7 additions & 0 deletions charts/amoro/templates/_pod.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@
readOnly: true
subPath: "jvm.properties"
{{- end -}}
{{- /* metric-reporters.yaml from config-map*/ -}}
{{- if or .Values.plugin.metricReporters }}
- name: conf
mountPath: {{ include "amoro.home" . }}/conf/plugins/metric-reporters.yaml
readOnly: true
subPath: "metric-reporters.yaml"
{{- end -}}
{{- /* flink install dir. if flink optimizer container enabled.
flink distribution package will be installed to here*/ -}}
{{- if .Values.optimizer.flink.enabled }}
Expand Down
11 changes: 11 additions & 0 deletions charts/amoro/templates/amoro-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ data:
jvm.properties: |
{{- . | nindent 4 }}
{{- end }}
{{- with .Values.plugin.metricReporters }}
## Helm chart provided metric reporters configurations
metric-reporters.yaml: |
metric-reporters:
{{- range . }}
- name: {{ .name }}
enabled: {{ .enabled }}
properties:
{{ .properties | toYaml | nindent 10 | trim}}
{{- end }}
{{- end }}
## Helm chart provided Amoro configurations
config.yaml: |
ams:
Expand Down
25 changes: 25 additions & 0 deletions charts/amoro/templates/amoro-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,28 @@ spec:
---
{{- end }}
{{- end }}
{{- range $reporter := .Values.plugin.metricReporters }}
{{- if and $reporter.enabled $reporter.properties.port $reporter.service}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "common.names.fullname" $ }}-{{ $reporter.name }}
labels:
{{- include "amoro.labels" $ | nindent 4 }}
{{- with $reporter.service.annotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ $reporter.service.type }}
ports:
- name: {{ tpl $reporter.name $ }}
port: {{ tpl $reporter.service.port $ }}
{{- if and (eq $reporter.service.type "NodePort") ($reporter.service.nodePort) }}
nodePort: {{ $reporter.service.nodePort }}
{{- end }}
targetPort: {{ $reporter.properties.port }}
selector:
{{- include "amoro.selectorLabels" $ | nindent 4 }}
---
{{- end }}
{{- end }}
16 changes: 15 additions & 1 deletion charts/amoro/tests/amoro-configmap_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,18 @@ tests:
path: data["config.yaml"]
pattern:
|
- name: local1
- name: local1
- it: Amoro configMap should reflect metric reporters
set:
plugin:
metricReporters:
- name: prometheus-exporter
enabled: true
properties:
port: 7001
asserts:
- matchRegex:
path: data["metric-reporters.yaml"]
pattern:
|
- name: prometheus-exporter
37 changes: 36 additions & 1 deletion charts/amoro/tests/amoro-service_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,39 @@ tests:
targetPort: 1261
documentSelector:
path: metadata.name
value: test-optimizing
value: test-optimizing
- it: Amoro Service for plugin metric reporters should reflect prometheus exporter configuration
set:
fullnameOverride: test
plugin:
metricReporters:
- name: prometheus-exporter
enabled: true
properties:
port: 7001
service:
type: ClusterIP
port: "7002"
nodePort: ~
annotations: {
"prometheus.io/scrape": "true",
"prometheus.io/path": "/metrics",
"prometheus.io/port": "7002"
}
asserts:
- contains:
path: spec.ports
content:
name: prometheus-exporter
port: 7002
targetPort: 7001
documentSelector:
path: metadata.name
value: test-prometheus-exporter
- isSubset:
path: metadata.annotations
content:
prometheus.io/port: "7002"
documentSelector:
path: metadata.name
value: test-prometheus-exporter
32 changes: 32 additions & 0 deletions charts/amoro/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,38 @@ optimizer:
image: "apache/amoro:0.6"
extra: []

## Configure the plugin that allows you to access the metric reporters and events listeners.
##
plugin:
##
## metric reporters
##
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"
## }

## Configure the ingress resource that allows you to access the
## Amoro installation. Set up the URL
## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/
Expand Down

0 comments on commit 6949253

Please sign in to comment.