fixing sentinel initContainer and updating redis

This commit is contained in:
DerLev 2023-04-14 14:23:33 +02:00
parent b0c8e2b26c
commit 1a6f680e6f
No known key found for this signature in database
GPG Key ID: 0670C3C78B052325
3 changed files with 695 additions and 245 deletions

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ spec:
spec:
initContainers:
- name: config
image: redis:6.2.3-alpine
image: redis:7.0.10-alpine
command: [ "sh", "-c" ]
args:
- |
@ -30,13 +30,13 @@ spec:
echo "this is redis-0, not updating config..."
else
echo "updating redis.conf..."
echo "slaveof $MASTER_FDQN 6379" >> /etc/redis/redis.conf
echo "replicaof $MASTER_FDQN 6379" >> /etc/redis/redis.conf
fi
else
echo "sentinel found, finding master"
MASTER="$(redis-cli -h sentinel -p 5000 sentinel get-master-addr-by-name mymaster | grep -E '(^redis-\d{1,})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})')"
echo "master found : $MASTER, updating redis.conf"
echo "slaveof $MASTER 6379" >> /etc/redis/redis.conf
echo "replicaof $MASTER 6379" >> /etc/redis/redis.conf
fi
volumeMounts:
- name: redis-config
@ -45,7 +45,7 @@ spec:
mountPath: /tmp/redis/
containers:
- name: redis
image: redis:6.2.3-alpine
image: redis:7.0.10-alpine
command: ["redis-server"]
args: ["/etc/redis/redis.conf"]
ports:
@ -70,7 +70,7 @@ spec:
storageClassName: "standard"
resources:
requests:
storage: 50Mi
storage: 64Mi
---
apiVersion: v1
kind: Service

View File

@ -15,14 +15,15 @@ spec:
spec:
initContainers:
- name: config
image: redis:6.2.3-alpine
image: redis:7.0.10-alpine
command: [ "sh", "-c" ]
args:
- |
REDIS_PASSWORD=a-very-complex-password-here
nodes=redis-0.redis,redis-1.redis,redis-2.redis
loop=$(echo $nodes | sed -e "s/,/\n/g")
for i in ${nodes//,/ }
for i in $loop
do
echo "finding master at $i"
MASTER=$(redis-cli --no-auth-warning --raw -h $i -a $REDIS_PASSWORD info replication | awk '{print $1}' | grep master_host: | cut -d ":" -f2)
@ -50,7 +51,7 @@ spec:
mountPath: /etc/redis/
containers:
- name: sentinel
image: redis:6.2.3-alpine
image: redis:7.0.10-alpine
command: ["redis-sentinel"]
args: ["/etc/redis/sentinel.conf"]
ports:
@ -72,7 +73,7 @@ spec:
storageClassName: "standard"
resources:
requests:
storage: 50Mi
storage: 64Mi
---
apiVersion: v1
kind: Service