{{ if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ include "cluster-autoscaler.fullname" . }}
  {{- if .Values.serviceMonitor.namespace }}
  namespace: {{ .Values.serviceMonitor.namespace }}
  {{- end }}
  labels:
    {{- range $key, $value := .Values.serviceMonitor.selector }}
      {{ $key }}: {{ $value | quote }}
    {{- end }}
spec:
  selector:
    matchLabels:
      app: {{ template "cluster-autoscaler.name" . }}
      release: {{ .Release.Name }}
  endpoints:
  - port: {{ .Values.service.portName }}
    interval: {{ .Values.serviceMonitor.interval }}
  namespaceSelector:
    any: true
{{ end }} 
