{{- if .Values.cluster.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ template "redis.fullname" . }}-slave
  labels:
    app: {{ template "redis.name" . }}
    chart: {{ template "redis.chart" . }}
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
  annotations:
{{- if .Values.slave.service.annotations }}
{{ toYaml .Values.slave.service.annotations | indent 4 }}
{{- end }}
spec:
  type: {{ .Values.slave.service.type }}
  {{ if eq .Values.slave.service.type "LoadBalancer" -}} {{ if .Values.slave.service.loadBalancerIP -}}
  loadBalancerIP: {{ .Values.slave.service.loadBalancerIP }}
  {{ end -}}
  {{- end -}}
  ports:
  - name: redis
    port: 6379
    targetPort: redis
  selector:
    app: {{ template "redis.name" . }}
    release: "{{ .Release.Name }}"
    role: slave
{{- end}}
