apiVersion: v1
kind: Service
metadata:
{{- if .Values.service.annotations }}
  annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
  name: {{ template "openldap.fullname" . }}
  labels:
    app: {{ template "openldap.name" . }}
    chart: {{ template "openldap.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
{{- if .Values.extraLabels }}
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
spec:
  clusterIP: {{ .Values.service.clusterIP | quote }}
{{- if .Values.service.externalIPs }}
  externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
{{- end }}
{{- if .Values.service.loadBalancerIP }}
  loadBalancerIP: {{ .Values.service.loadBalancerIP | quote }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
  loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }}
{{- end }}
  ports:
    - name: ldap-port
      protocol: TCP
      port: {{ .Values.service.ldapPort }}
      targetPort: ldap-port
    - name: ssl-ldap-port
      protocol: TCP
      port: {{ .Values.service.sslLdapPort }}
      targetPort: ssl-ldap-port
  selector:
    app: {{ template "openldap.name" . }}
    release: {{ .Release.Name }}
  type: {{ .Values.service.type }}
