apiVersion: v1
kind: Service
metadata:
  name: {{ template "dex.fullname" . }}
  labels:
    app: {{ template "dex.name" . }}
    chart: {{ template "dex.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
{{- if .Values.service.annotations }}
  annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
spec:
  type: {{ .Values.service.type}}
  sessionAffinity: None
  ports:
{{- range .Values.ports }}
  - name: {{ .name }} 
    port: {{ .containerPort }}
    targetPort: {{ .containerPort}}
{{- if and (eq "NodePort" $.Values.service.type) (hasKey . "nodePort") }}
    nodePort: {{ .nodePort }}
{{- end}}
{{- end}}
{{- if hasKey .Values.service "externalIPs" }}
  externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
{{- end }}
  selector:
    app: {{ template "dex.name" . }}
    release: {{ .Release.Name | quote }}
