---
apiVersion: v1
kind: Service
metadata:
  name: {{ template "nextcloud.fullname" . }}
  {{- with .Values.service.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  labels:
    {{- include "nextcloud.labels"  ( dict "component" "app"  "rootContext" $ ) | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  {{- if (eq .Values.service.type "LoadBalancer") }}
  {{- with .Values.service.loadBalancerIP }}
  loadBalancerIP: {{ . }}
  {{- end }}
  {{- end }}
  {{- with .Values.service.ipFamilies }}
  ipFamilies:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  {{- with .Values.service.ipFamilyPolicy }}
  ipFamilyPolicy: {{ . }}
  {{- end }}
  ports:
    - port: {{ .Values.service.port }}
      targetPort: {{ .Values.nextcloud.containerPort }}
      protocol: TCP
      name: http
      {{- with .Values.service.nodePort }}
      nodePort: {{ . }}
      {{- end }}
  selector:
    app.kubernetes.io/name: {{ include "nextcloud.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/component: app
