Merge pull request #53 from schmiddim/master

Create FDQN for Redis dynamicly
This commit is contained in:
Marcel Dempers 2021-01-24 10:03:53 +00:00 committed by GitHub
commit 5c86259aff
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"
@ -82,4 +83,4 @@ spec:
targetPort: 6379
name: redis
selector:
app: redis
app: redis