blob: a0d073e46bb588a0575980e443b835601af77be7 [file] [log] [blame]
Oleksandr Kozachenkob0093492023-09-06 21:43:47 +02001{{- /*
2Copyright VMware, Inc.
3SPDX-License-Identifier: APACHE-2.0
4*/}}
5
6{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
7apiVersion: monitoring.coreos.com/v1
8kind: ServiceMonitor
9metadata:
10 name: {{ template "common.names.fullname" . }}
11 namespace: {{ default (include "common.names.namespace" .) .Values.metrics.serviceMonitor.namespace }}
12 labels: {{- include "common.labels.standard" . | nindent 4 }}
13 app.kubernetes.io/component: keycloak
14 {{- if .Values.metrics.serviceMonitor.labels }}
15 {{- include "common.tplvalues.render" (dict "value" .Values.metrics.serviceMonitor.labels "context" $) | nindent 4 }}
16 {{- end }}
17 {{- if .Values.commonLabels }}
18 {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
19 {{- end }}
20 {{- if .Values.commonAnnotations }}
21 annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
22 {{- end }}
23spec:
24 {{- if .Values.metrics.serviceMonitor.jobLabel }}
25 jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel }}
26 {{- end }}
27 endpoints:
28 {{- $defaultEndpoint := pick .Values.metrics.serviceMonitor "port" "interval" "scrapeTimeout" "relabelings" "metricRelabelings" "honorLabels" }}
29 {{- $endpoints := ternary (.Values.metrics.serviceMonitor.endpoints) (list (dict "path" .Values.metrics.serviceMonitor.path)) (empty .Values.metrics.serviceMonitor.path) }}
30 {{- range $endpoints }}
31 {{- $endpoint := merge . $defaultEndpoint }}
32 - port: {{ $endpoint.port }}
33 path: {{ include "common.tplvalues.render" ( dict "value" $endpoint.path "context" $) }}
34 {{- if $endpoint.interval }}
35 interval: {{ $endpoint.interval }}
36 {{- end }}
37 {{- if $endpoint.scrapeTimeout }}
38 scrapeTimeout: {{ $endpoint.scrapeTimeout }}
39 {{- end }}
40 {{- if $endpoint.relabelings }}
41 relabelings: {{- include "common.tplvalues.render" ( dict "value" $endpoint.relabelings "context" $) | nindent 6 }}
42 {{- end }}
43 {{- if $endpoint.metricRelabelings }}
44 metricRelabelings: {{- include "common.tplvalues.render" ( dict "value" $endpoint.metricRelabelings "context" $) | nindent 6 }}
45 {{- end }}
46 {{- if $endpoint.honorLabels }}
47 honorLabels: {{ $endpoint.honorLabels }}
48 {{- end }}
49 {{- end }}
50 namespaceSelector:
51 matchNames:
52 - {{ include "common.names.namespace" . | quote }}
53 selector:
54 matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
55 {{- if .Values.metrics.serviceMonitor.selector }}
56 {{- include "common.tplvalues.render" (dict "value" .Values.metrics.serviceMonitor.selector "context" $) | nindent 6 }}
57 {{- end }}
58 app.kubernetes.io/component: metrics
59{{- end }}