| Giorgi Lekveishvili | 725bb39 | 2023-05-05 18:24:27 +0400 | [diff] [blame] | 1 | {{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) .Values.controller.metrics.enabled .Values.controller.metrics.serviceMonitor.enabled -}} |
| 2 | apiVersion: monitoring.coreos.com/v1 |
| 3 | kind: ServiceMonitor |
| 4 | metadata: |
| 5 | name: {{ include "ingress-nginx.controller.fullname" . }} |
| 6 | {{- if .Values.controller.metrics.serviceMonitor.namespace }} |
| 7 | namespace: {{ .Values.controller.metrics.serviceMonitor.namespace | quote }} |
| 8 | {{- end }} |
| 9 | labels: |
| 10 | {{- include "ingress-nginx.labels" . | nindent 4 }} |
| 11 | app.kubernetes.io/component: controller |
| 12 | {{- if .Values.controller.metrics.serviceMonitor.additionalLabels }} |
| 13 | {{- toYaml .Values.controller.metrics.serviceMonitor.additionalLabels | nindent 4 }} |
| 14 | {{- end }} |
| 15 | spec: |
| 16 | endpoints: |
| 17 | - port: metrics |
| 18 | interval: {{ .Values.controller.metrics.serviceMonitor.scrapeInterval }} |
| 19 | {{- if .Values.controller.metrics.serviceMonitor.honorLabels }} |
| 20 | honorLabels: true |
| 21 | {{- end }} |
| 22 | {{- if .Values.controller.metrics.serviceMonitor.metricRelabelings }} |
| 23 | metricRelabelings: {{ toYaml .Values.controller.metrics.serviceMonitor.metricRelabelings | nindent 8 }} |
| 24 | {{- end }} |
| 25 | {{- if .Values.controller.metrics.serviceMonitor.jobLabel }} |
| 26 | jobLabel: {{ .Values.controller.metrics.serviceMonitor.jobLabel | quote }} |
| 27 | {{- end }} |
| 28 | {{- if .Values.controller.metrics.serviceMonitor.namespaceSelector }} |
| 29 | namespaceSelector: {{ toYaml .Values.controller.metrics.serviceMonitor.namespaceSelector | nindent 4 }} |
| 30 | {{ else }} |
| 31 | namespaceSelector: |
| 32 | matchNames: |
| 33 | - {{ .Release.Namespace }} |
| 34 | {{- end }} |
| 35 | {{- if .Values.controller.metrics.serviceMonitor.targetLabels }} |
| 36 | targetLabels: |
| 37 | {{- range .Values.controller.metrics.serviceMonitor.targetLabels }} |
| 38 | - {{ . }} |
| 39 | {{- end }} |
| 40 | {{- end }} |
| 41 | selector: |
| 42 | matchLabels: |
| 43 | {{- include "ingress-nginx.selectorLabels" . | nindent 6 }} |
| 44 | app.kubernetes.io/component: controller |
| 45 | {{- end }} |