{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) .Values.lvmNode.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ template "lvmlocalpv.fullname" . }}-node-servicemonitor
  namespace: {{- .Release.Namespace }}
  labels:
    #release: prometheus  # Adjust to match your Prometheus Operator's release name
    {{- .Values.lvmNode.serviceMonitor.labels | toYaml | nindent 4 }}
spec:
  selector:
    matchLabels:
    {{- include "lvmlocalpv.lvmNode.labels" . | nindent 6 }}
  namespaceSelector:
    matchNames:
      - {{- .Release.Namespace }}
  endpoints:
    - port: metrics
      path: /metrics
      interval: 30s
      scrapeTimeout: 10s
{{- end }}

