mirror of
https://github.com/marcel-dempers/docker-development-youtube-series.git
synced 2025-06-06 17:01:30 +00:00
fixing sentinel initContainer and updating redis
This commit is contained in:
parent
b0c8e2b26c
commit
1a6f680e6f
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: config
|
- name: config
|
||||||
image: redis:6.2.3-alpine
|
image: redis:7.0.10-alpine
|
||||||
command: [ "sh", "-c" ]
|
command: [ "sh", "-c" ]
|
||||||
args:
|
args:
|
||||||
- |
|
- |
|
||||||
@ -30,13 +30,13 @@ spec:
|
|||||||
echo "this is redis-0, not updating config..."
|
echo "this is redis-0, not updating config..."
|
||||||
else
|
else
|
||||||
echo "updating redis.conf..."
|
echo "updating redis.conf..."
|
||||||
echo "slaveof $MASTER_FDQN 6379" >> /etc/redis/redis.conf
|
echo "replicaof $MASTER_FDQN 6379" >> /etc/redis/redis.conf
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "sentinel found, finding master"
|
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})')"
|
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 "master found : $MASTER, updating redis.conf"
|
||||||
echo "slaveof $MASTER 6379" >> /etc/redis/redis.conf
|
echo "replicaof $MASTER 6379" >> /etc/redis/redis.conf
|
||||||
fi
|
fi
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: redis-config
|
- name: redis-config
|
||||||
@ -45,7 +45,7 @@ spec:
|
|||||||
mountPath: /tmp/redis/
|
mountPath: /tmp/redis/
|
||||||
containers:
|
containers:
|
||||||
- name: redis
|
- name: redis
|
||||||
image: redis:6.2.3-alpine
|
image: redis:7.0.10-alpine
|
||||||
command: ["redis-server"]
|
command: ["redis-server"]
|
||||||
args: ["/etc/redis/redis.conf"]
|
args: ["/etc/redis/redis.conf"]
|
||||||
ports:
|
ports:
|
||||||
@ -70,7 +70,7 @@ spec:
|
|||||||
storageClassName: "standard"
|
storageClassName: "standard"
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 50Mi
|
storage: 64Mi
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
|
@ -15,14 +15,15 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: config
|
- name: config
|
||||||
image: redis:6.2.3-alpine
|
image: redis:7.0.10-alpine
|
||||||
command: [ "sh", "-c" ]
|
command: [ "sh", "-c" ]
|
||||||
args:
|
args:
|
||||||
- |
|
- |
|
||||||
REDIS_PASSWORD=a-very-complex-password-here
|
REDIS_PASSWORD=a-very-complex-password-here
|
||||||
nodes=redis-0.redis,redis-1.redis,redis-2.redis
|
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
|
do
|
||||||
echo "finding master at $i"
|
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)
|
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/
|
mountPath: /etc/redis/
|
||||||
containers:
|
containers:
|
||||||
- name: sentinel
|
- name: sentinel
|
||||||
image: redis:6.2.3-alpine
|
image: redis:7.0.10-alpine
|
||||||
command: ["redis-sentinel"]
|
command: ["redis-sentinel"]
|
||||||
args: ["/etc/redis/sentinel.conf"]
|
args: ["/etc/redis/sentinel.conf"]
|
||||||
ports:
|
ports:
|
||||||
@ -72,7 +73,7 @@ spec:
|
|||||||
storageClassName: "standard"
|
storageClassName: "standard"
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 50Mi
|
storage: 64Mi
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
|
Loading…
x
Reference in New Issue
Block a user