apiVersion: v1
kind: Service
metadata:
{{- if .Values.service.annotations }}
  annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
  labels:
    app: {{ template "inbucket.name" . }}
    chart: {{ template "inbucket.chart" . }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template "inbucket.fullname" . }}
spec:
  type: "{{ .Values.service.type }}"
  clusterIP: "{{ .Values.service.clusterIP }}"
{{- if .Values.service.externalIPs }}
  externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
{{- end }}
{{- if .Values.service.loadBalancerIP }}
  loadBalancerIP: "{{ .Values.service.loadBalancerIP }}"
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
  loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }}
{{- end }}
  ports:
    - name: http
      port: {{ .Values.service.port.http }}
      protocol: TCP
      targetPort: http
      {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort.http))) }}
      nodePort: {{ .Values.service.nodePort.http }}
      {{- end }}
    - name: smtp
      port: {{ .Values.service.port.smtp }}
      protocol: TCP
      targetPort: smtp
      {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort.smtp))) }}
      nodePort: {{ .Values.service.nodePort.smtp }}
      {{- end }}
  selector:
    app: {{ template "inbucket.name" . }}
    release: {{ .Release.Name }}
