apiVersion: v1
kind: Service
metadata:
  name: {{ .Release.Name }}-gerrit-service
  labels:
    app.kubernetes.io/component: gerrit
    app.kubernetes.io/instance: {{ .Release.Name }}
    chart: {{ template "gerrit.chart" . }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
    {{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels  | indent 4 }}
    {{- end }}
  {{- if .Values.gerrit.service.additionalAnnotations }}
  annotations:
{{ toYaml .Values.gerrit.service.additionalAnnotations  | indent 4 }}
  {{- end }}
spec:
  {{ with .Values.gerrit.service }}
  {{- if .loadBalancerSourceRanges -}}
  loadBalancerSourceRanges:
{{- range .loadBalancerSourceRanges }}
    - {{ . | quote }}
{{- end }}
  {{- end }}
  ports:
  - name: http
    port: {{ .http.port }}
    targetPort: 8080
  {{- if .ssh.enabled }}
  - name: ssh
    port: {{ .ssh.port }}
    targetPort: 29418
  {{- end }}
  type: {{ .type }}
  externalTrafficPolicy: {{ .externalTrafficPolicy }}
  {{- end }}
  selector:
    app.kubernetes.io/component: gerrit
    app.kubernetes.io/instance: {{ .Release.Name }}

