{{- include "seaweedfs.compat" . -}}
{{- if .Values.worker.enabled }}
{{- if .Values.worker.metricsPort }}
{{- if .Values.global.seaweedfs.monitoring.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ include "seaweedfs.fullname" . }}-worker
  namespace: {{ .Release.Namespace }}
  labels:
    app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/component: worker
    {{- with .Values.global.seaweedfs.monitoring.additionalLabels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
{{- with .Values.worker.serviceMonitor.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
{{- end }}
spec:
  endpoints:
    - interval: 30s
      port: metrics
      scrapeTimeout: 5s
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
      app.kubernetes.io/component: worker
{{- end }}
{{- end }}
{{- end }}
