I have set-up redis-cluster on Kubernetes (Google Container Engine). Referenced from : https://github.com/zuxqoj/kubernetes-redis-cluster/blob/master/README-using-statefulset.md
So the current state is that, we have 6 pods under a single node of Kubernetes Cluster, 3 pods as masters and 3 pods as slaves. Have brought all the pods into redis-cluster and things are working fine.
However, when I try to bring down one of the master / slave pod, kubernetes automatically starts a new pod with a new IP. And the new IP is being auto updated in all other pods node configuration, except its own node configuration. Is there something I am missing?
I am using redis 4.0.0
Redis Cluster Yaml: https://drive.google.com/open?id=1oSQzYu-pAJmehaAfU_HdIa3qAJBx1n5C
You need to update the IP of the new pod in nodes.conf. You can do it by running this script in the initialization of the pod.
#!/bin/sh
set -e
REDIS_NODES_FILE="/data/nodes.conf"
if [ -f ${REDIS_NODES_FILE} ]; then
if [ -z "${POD_IP}" ]; then
echo "Unable to determine Pod IP address!"
exit 1
fi
echo "Updating my IP to ${POD_IP}"
sed -i.bak -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${POD_IP}/" ${REDIS_NODES_FILE}
fi
Originated from: https://github.com/antirez/redis/issues/5417
Try using DNS hostnames instead of IP addresses.
See Helm charts that just do that: