apiVersion: v1
kind: Service
metadata:
  name: {{ template "parse.fullname" . }}
  labels:
    app: {{ template "parse.name" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
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:
    app: {{ template "parse.name" . }}
    release: "{{ .Release.Name }}"
