diff --git a/charts/celeborn/templates/_helpers.tpl b/charts/celeborn/templates/_helpers.tpl index 6224a816c..770112936 100644 --- a/charts/celeborn/templates/_helpers.tpl +++ b/charts/celeborn/templates/_helpers.tpl @@ -155,3 +155,78 @@ Create the name of the worker podmonitor to use {{- define "celeborn.workerPodMonitorName" -}} {{ include "celeborn.fullname" . }}-worker-podmonitor {{- end }} + +{{/* +Create master annotations if metrics enables +*/}} +{{- define "celeborn.masterMetricsAnnotation" -}} +{{- $metricsEnabled := true -}} +{{- $metricsPath := "/metrics/prometheus" -}} +{{- $masterPort := 9098 -}} +{{- range $key, $val := .Values.celeborn }} +{{- if eq $key "celeborn.metrics.enabled" }} +{{- $metricsEnabled = $val -}} +{{- end }} +{{- if eq $key "celeborn.metrics.prometheus.path" }} +{{- $metricsPath = $val -}} +{{- end }} +{{- if eq $key "celeborn.master.http.port" }} +{{- $masterPort = $val -}} +{{- end }} +{{- end }} +{{- if eq (toString $metricsEnabled) "true" -}} +prometheus.io/path: {{ $metricsPath }} +prometheus.io/port: '{{ $masterPort }}' +prometheus.io/scheme: 'http' +prometheus.io/scrape: 'true' +{{- end }} +{{- end }} + +{{/* +Create worker annotations if metrics enables +*/}} +{{- define "celeborn.workerMetricsAnnotation" -}} +{{- $metricsEnabled := true -}} +{{- $metricsPath := "/metrics/prometheus" -}} +{{- $workerPort := 9096 -}} +{{- range $key, $val := .Values.celeborn }} +{{- if eq $key "celeborn.metrics.enabled" }} +{{- $metricsEnabled = $val -}} +{{- end }} +{{- if eq $key "celeborn.metrics.prometheus.path" }} +{{- $metricsPath = $val -}} +{{- end }} +{{- if eq $key "celeborn.worker.http.port" }} +{{- $workerPort = $val -}} +{{- end }} +{{- end }} +{{- if eq (toString $metricsEnabled) "true" -}} +prometheus.io/path: {{ $metricsPath }} +prometheus.io/port: '{{ $workerPort }}' +prometheus.io/scheme: 'http' +prometheus.io/scrape: 'true' +{{- end }} +{{- end }} + +{{/* +Create worker Service http port params if metrics enables +*/}} +{{- define "celeborn.workerServicePort" -}} +{{- $metricsEnabled := true -}} +{{- $workerPort := 9096 -}} +{{- range $key, $val := .Values.celeborn }} +{{- if eq $key "celeborn.metrics.enabled" }} +{{- $metricsEnabled = $val -}} +{{- end }} +{{- if eq $key "celeborn.worker.http.port" }} +{{- $workerPort = $val -}} +{{- end }} +{{- end }} +{{- if eq (toString $metricsEnabled) "true" -}} +ports: + - port: {{ $workerPort }} + targetPort: {{ $workerPort }} + protocol: TCP + name: celeborn-worker-http +{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/celeborn/templates/master/service.yaml b/charts/celeborn/templates/master/service.yaml index aee0ce1df..73a7c229b 100644 --- a/charts/celeborn/templates/master/service.yaml +++ b/charts/celeborn/templates/master/service.yaml @@ -21,6 +21,8 @@ metadata: name: {{ include "celeborn.masterServiceName" . }} labels: {{- include "celeborn.labels" . | nindent 4 }} + annotations: + {{- include "celeborn.masterMetricsAnnotation" . | nindent 4 }} spec: selector: {{- include "celeborn.selectorLabels" . | nindent 4 }} diff --git a/charts/celeborn/templates/worker/service.yaml b/charts/celeborn/templates/worker/service.yaml index 2f8b1ec24..f56483054 100644 --- a/charts/celeborn/templates/worker/service.yaml +++ b/charts/celeborn/templates/worker/service.yaml @@ -21,9 +21,12 @@ metadata: name: {{ include "celeborn.workerServiceName" . }} labels: {{- include "celeborn.labels" . | nindent 4 }} + annotations: + {{- include "celeborn.workerMetricsAnnotation" . | nindent 4 }} spec: selector: {{- include "celeborn.selectorLabels" . | nindent 4 }} app.kubernetes.io/role: worker type: {{ .Values.service.type }} clusterIP: None + {{- include "celeborn.workerServicePort" . | nindent 2 }}