apiVersion: v1
kind: ConfigMap
metadata:
  name: redis-config
data:
  update-node.sh: |
    #!/bin/sh
    REDIS_NODES="/data/nodes.conf"
    sed -i -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${MY_POD_IP}/" ${REDIS_NODES}
    exec "$@"
  redis.conf: |+
    {{- if .Values.redis.port }}
    port {{ .Values.redis.port }}
    {{- else }}
    port 6379
    {{- end }}
    timeout 0
    tcp-keepalive 300
    daemonize no
    protected-mode no
    appendonly {{ .Values.redis.enabledAppendonly }}

    cluster-enabled yes
    cluster-config-file /data/nodes.conf
    cluster-node-timeout 15000
    cluster-slave-validity-factor 10
    cluster-migration-barrier 1
    cluster-require-full-coverage no
    cluster-allow-reads-when-down no

    logfile "/data/redis.log"
    dir /data