{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.serviceMonitor.enabled ) }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ include "frontend.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "frontend.labels" . | nindent 4 }}
  {{- if .Values.serviceMonitor.additionalLabels }}
    {{- toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }}
  {{- end }}
spec:
  endpoints:
    {{- .Values.serviceMonitor.scrapeConfigs | toYaml | nindent 4 }}
  selector:
    matchLabels:
      {{- include "frontend.selectorLabels" . | nindent 6 }}
{{- end }}
