{{- if .Values.metrics.enabled }}
---
apiVersion: v1
kind: Service
metadata:
  name: {{ template "nextcloud.fullname" . }}-metrics
  labels:
    {{- include "nextcloud.labels"  ( dict "component" "metrics"  "rootContext" $ ) | nindent 4 }}
    {{- with .Values.metrics.service.labels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  {{- with .Values.metrics.service.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  type: {{ .Values.metrics.service.type }}
  {{- if eq .Values.metrics.service.type "LoadBalancer" }}
  {{- with .Values.metrics.service.loadBalancerIP }}
  loadBalancerIP: {{ . }}
  {{- end }}
  {{- end }}
  ports:
    - name: metrics
      port: 9205
      targetPort: metrics
  selector:
    {{- include "nextcloud.selectorLabels"  ( dict "component" "metrics"  "rootContext" $ ) | nindent 4 }}
{{- end }}
