apiVersion: v1
kind: Service
metadata:
  name: {{ template "redmine.fullname" . }}
  labels: {{- include "redmine.labels" . | nindent 4 }}
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" }}
  loadBalancerSourceRanges: {{ .Values.service.loadBalancerSourceRanges }}
  {{ end }}
  {{- if (and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP))) }}
  loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  {{- end }}
  ports:
    - name: http-redmine
      port: {{ .Values.service.port }}
      targetPort: http-redmine
      {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.http)))}}
      nodePort: {{ .Values.service.nodePorts.http }}
      {{- end }}
  selector: {{- include "redmine.matchLabels" . | nindent 4 }}
