apiVersion: v1
kind: Service
metadata:
  name: {{ template "redis-ha.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
{{ include "labels.standard" . | indent 4 }}
{{- if and ( .Values.exporter.enabled ) ( .Values.exporter.serviceMonitor.enabled ) }}
    servicemonitor: enabled
{{- end }}
  annotations:
  {{- if .Values.serviceAnnotations }}
{{ toYaml .Values.serviceAnnotations | indent 4 }}
  {{- end }}
spec:
  type: ClusterIP
  clusterIP: None
  ports:
  - name: server
    port: {{ .Values.redis.port }}
    protocol: TCP
    targetPort: redis
  - name: sentinel
    port: {{ .Values.sentinel.port }}
    protocol: TCP
    targetPort: sentinel
{{- if .Values.exporter.enabled }}
  - name: exporter-port
    port: {{ .Values.exporter.port }}
    protocol: TCP
    targetPort: exporter-port
{{- end }}
  selector:
    release: {{ .Release.Name }}
    app: {{ template "redis-ha.name" . }}