apiVersion: v1
kind: Service
metadata:
  name: {{ include "parse.fullname" . }}
  labels: {{ include "parse.labels" . | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  {{- if and (.Values.service.loadBalancerIP) (eq .Values.service.type "LoadBalancer") }}
  loadBalancerIP: {{ .Values.service.loadBalancerIP | quote }}
  {{- end }}
  {{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }}
  externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
  {{- end }}
  ports:
    - name: server-http
      port: {{ .Values.server.port }}
      targetPort: server-http
    - name: dashboard-http
      port: {{ .Values.service.port }}
      targetPort: dashboard-http
      {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.http)))}}
      nodePort: {{ .Values.service.nodePorts.http }}
      {{- end }}
  selector: {{ include "parse.matchLabels" . | nindent 4 }}
