** Please be patient while the chart is being deployed **

{{ if .Values.usePassword }}
To get your password run:

    export REDIS_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "redis-cluster.secretName" . }} -o jsonpath="{.data.redis-password}" | base64 --decode)
{{- end }}

{{- if .Values.cluster.externalAccess.enabled }}

To connect to your Redis server from outside the cluster check the following information:

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "redis-cluster.fullname" . }}'

    You will have a different external IP for each Redis node. Get the external ip from `-external` suffixed services: `kubectl get svc`.
    Redis port: {{ .Values.cluster.externalAccess.service.port }}

    {{- if not .Values.cluster.externalAccess.service.loadBalancerIP }}
    Once the LoadBalancerIPs are ready, you need to provide them and perform a Helm Upgrade:

    helm upgrade {{ .Release.Name }} --set "cluster.externalAccess.enabled=true,cluster.externalAccess.service.type=LoadBalancer{{- $root := . }}{{ $count := .Values.cluster.nodes | int }}{{ range $i, $v := until $count }},cluster.externalAccess.service.loadBalancerIP[{{ $i }}]=load-balancerip-{{- $i }}{{- end }}" bitnami/redis
    Where loadbalancer-ip-i are the LoadBalancerIPs provided by the cluster.
    {{- else -}}
    {{- if .Values.cluster.init -}}
    INFO: The Job to create the cluster will be created.
    {{- end -}}

    To connect to your database from outside the cluster execute the following commands:

    export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "redis-cluster.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
    redis-cli -c -h $SERVICE_IP -p {{ .Values.service.port }} {{- if .Values.usePassword }} -a $REDIS_PASSWORD{{ end }}
    {{- end }}

{{- else }}

You have deployed a Redis Cluster accessible only from within you Kubernetes Cluster.

{{- if .Values.cluster.init -}}
INFO: The Job to create the cluster will be created.
{{- end -}}

To connect to your Redis cluster:

1. Run a Redis pod that you can use as a client:

kubectl run --namespace {{ .Release.Namespace }} {{ template "redis-cluster.fullname" . }}-client --rm --tty -i --restart='Never' \
{{ if .Values.usePassword }} --env REDIS_PASSWORD=$REDIS_PASSWORD \{{ end }}
{{- if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}--labels="{{ template "redis-cluster.fullname" . }}-client=true" \{{- end }}
--image {{ template "redis-cluster.image" . }} -- bash

2. Connect using the Redis CLI:

redis-cli -c -h {{ template "redis-cluster.fullname" . }}{{ if .Values.usePassword }} -a $REDIS_PASSWORD{{ end }}

{{ if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}
Note: Since NetworkPolicy is enabled, only pods with label
{{ template "redis-cluster.fullname" . }}-client=true"
will be able to connect to redis.
{{- end -}}
{{- end -}}

{{- include "redis-cluster.validateValues" . }}
{{- include "redis-cluster.checkRollingTags" . }}
