apiVersion: v1
kind: Service
metadata:
  name: {{ template "jenkins.fullname" . }}
  labels: {{- include "jenkins.labels" . | nindent 4 }}
  {{- if .Values.service.annotations }}
  annotations: {{ include "jenkins.tplValue" ( dict "value" .Values.service.annotations "context" $) | nindent 4 }}
  {{- end }}
spec:
  type: {{ .Values.service.type }}
  {{- if or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") }}
  externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
  {{- end }}
  {{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP)) }}
  loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  {{- end }}
  ports:
    - name: http
      port: {{ .Values.service.port }}
      targetPort: http
      {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.http)) }}
      nodePort: {{ .Values.service.nodePorts.http }}
      {{- end }}
    - name: https
      port: {{ .Values.service.httpsPort }}
      targetPort: https
      {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.https)) }}
      nodePort: {{ .Values.service.nodePorts.https }}
      {{- end }}
  selector: {{- include "jenkins.matchLabels" . | nindent 4 }}
