Update redis-statefulset.yaml

Create FDQN  for Redis dynamicly
This commit is contained in:
Michael 2020-11-06 17:32:32 +01:00 committed by GitHub
parent f8ac773d6a
commit 10aad91e3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,7 @@ spec:
cp /tmp/redis/redis.conf /etc/redis/redis.conf
echo "finding master..."
MASTER_FDQN=`hostname -f | sed -e 's/redis-[0-9]\./redis-0./'`
if [ "$(redis-cli -h sentinel -p 5000 ping)" != "PONG" ]; then
echo "master not found, defaulting to redis-0"
@ -29,7 +30,7 @@ spec:
echo "this is redis-0, not updating config..."
else
echo "updating redis.conf..."
echo "slaveof redis-0.redis.redis.svc.cluster.local 6379" >> /etc/redis/redis.conf
echo "slaveof $MASTER_FDQN 6379" >> /etc/redis/redis.conf
fi
else
echo "sentinel found, finding master"