apiVersion: v1
kind: Service
metadata:
  name: {{ template "owncloud.fullname" . }}
  labels:
    app: {{ template "owncloud.fullname" . }}
    chart: {{ template "owncloud.chart" . }}
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  type: {{ .Values.service.type }}
  {{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }}
  externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
  {{- end }}
  {{- if eq .Values.service.type "LoadBalancer" }}
  loadBalancerIP: {{ default "" .Values.service.loadBalancerIP }}
  {{- end }}
  ports:
    - name: http
      port: {{ .Values.service.port }}
      targetPort: http
      {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.http)))}}
      nodePort: {{ .Values.service.nodePorts.http }}
      {{- end }}
  selector:
    app: {{ template "owncloud.fullname" . }}
