{{- if .Values.nodeExporter.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ template "prometheus-operator.fullname" . }}-node-exporter
  namespace: {{ template "prometheus-operator.namespace" . }}
  labels:
    app: {{ template "prometheus-operator.name" . }}-node-exporter
{{ include "prometheus-operator.labels" . | indent 4 }}
spec:
  jobLabel: {{ .Values.nodeExporter.jobLabel }}
  selector:
    matchLabels:
      app: prometheus-node-exporter
      release: {{ $.Release.Name }}
  endpoints:
  - port: metrics
    {{- if .Values.nodeExporter.serviceMonitor.interval }}
    interval: {{ .Values.nodeExporter.serviceMonitor.interval }}
    {{- end }}
    {{- if .Values.nodeExporter.serviceMonitor.scrapeTimeout }}
    scrapeTimeout: {{ .Values.nodeExporter.serviceMonitor.scrapeTimeout }}
    {{- end }}
{{- if .Values.nodeExporter.serviceMonitor.metricRelabelings }}
    metricRelabelings:
{{ tpl (toYaml .Values.nodeExporter.serviceMonitor.metricRelabelings | indent 4) . }}
{{- end }}
{{- if .Values.nodeExporter.serviceMonitor.relabelings }}
    relabelings:
{{ toYaml .Values.nodeExporter.serviceMonitor.relabelings | indent 4 }}
{{- end }}
{{- end }}
