Created
August 12, 2022 03:26
-
-
Save jithin-scaria/f9c7e5b67022c26044b5b18edffc715f to your computer and use it in GitHub Desktop.
Redis Cluster on Kubernetes - startup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: redis-startup | |
namespace: redis | |
data: | |
redis-startup.sh: | | |
#!/bin/sh | |
if [ -f "/conf/nodes-6379.conf" ]; then | |
echo "Cluster details exists /conf/nodes-6379.conf.. starting script to do CLUSTER MEET when node is up" | |
while : | |
do | |
pong=$(timeout 5 redis-cli -c -a admin ping) | |
if [ ${pong} == 'PONG' ];then | |
nslookup redis.redis.svc.cluster.local | grep "Address:" | tail -n +2 | awk '{print "CLUSTER MEET " $2 " 6379"}' > /tmp/redis_meet_commands.txt | |
nslookup redis.redis.svc.cluster.local | grep "Address:" | tail -n +2 | awk '{print $2}' > /tmp/redis_ip_list.txt | |
echo "IP list" | |
cat /tmp/redis_ip_list.txt | |
echo "Cluster meet commands" | |
cat /tmp/redis_meet_commands.txt | |
while read line | |
do | |
echo "Cluster meet applying on ${line}" | |
cat /tmp/redis_meet_commands.txt | redis-cli -c -a admin -h ${line} | |
done < /tmp/redis_ip_list.txt | |
exit 0 | |
fi | |
sleep 10 | |
done | |
else | |
echo "Cluster details doesn't exist .. A new node" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment