{{- if and .Values.operator.enabled .Values.operator.prometheus.enabled .Values.operator.prometheus.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: cilium-operator
  namespace: {{ .Values.operator.prometheus.serviceMonitor.namespace | default .Release.Namespace }}
  labels:
    {{- with .Values.operator.prometheus.serviceMonitor.labels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  annotations:
    {{- with .Values.operator.prometheus.serviceMonitor.annotations }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
spec:
  selector:
    matchLabels:
      io.cilium/app: operator
      name: cilium-operator
  namespaceSelector:
    matchNames:
    - {{ .Release.Namespace }}
  endpoints:
  - port: metrics
    interval: 10s
    honorLabels: true
    path: /metrics
  targetLabels:
  - io.cilium/app
{{- end }}
