# helm_charts_mongodb-service-client.yaml
{{- if .Values.clientService.enabled -}}
# An optional headless service for client applications to use
apiVersion: v1
kind: Service
metadata:
  annotations:
  {{- if .Values.serviceAnnotations }}
{{ toYaml .Values.serviceAnnotations | indent 4 }}
  {{- end }}
  labels:
    app: {{ template "mongodb-replicaset.name" . }}
    chart: {{ template "mongodb-replicaset.chart" . }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
{{- if .Values.extraLabels }}
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
  name: {{ template "mongodb-replicaset.fullname" . }}-client
  namespace: {{ template "mongodb-replicaset.namespace" . }}
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: mongodb
      port: {{ .Values.port }}
{{- if .Values.metrics.enabled }}
    - name: metrics
      port: {{ .Values.metrics.port }}
      targetPort: metrics
{{- end }}
  selector:
    app: {{ template "mongodb-replicaset.name" . }}
    release: {{ .Release.Name }}
{{- end -}}