fix(dlob): run redis as single-node cluster
This commit is contained in:
@@ -32,7 +32,48 @@ spec:
|
|||||||
- name: redis
|
- name: redis
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: POD_IP
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: status.podIP
|
||||||
ports:
|
ports:
|
||||||
- name: redis
|
- name: redis
|
||||||
containerPort: 6379
|
containerPort: 6379
|
||||||
args: ["--save", "", "--appendonly", "no"]
|
# DLOB redis client uses ioredis Cluster when RUNNING_LOCAL=true and LOCAL_CACHE=true.
|
||||||
|
# We run a single-node Redis Cluster (no TLS) and assign all slots on startup.
|
||||||
|
command: ["/bin/sh", "-lc"]
|
||||||
|
args:
|
||||||
|
- |
|
||||||
|
exec redis-server \
|
||||||
|
--save "" \
|
||||||
|
--appendonly no \
|
||||||
|
--protected-mode no \
|
||||||
|
--bind 0.0.0.0 \
|
||||||
|
--cluster-enabled yes \
|
||||||
|
--cluster-config-file /data/nodes.conf \
|
||||||
|
--cluster-node-timeout 5000 \
|
||||||
|
--cluster-require-full-coverage no \
|
||||||
|
--cluster-announce-ip "${POD_IP}" \
|
||||||
|
--cluster-announce-port 6379 \
|
||||||
|
--cluster-announce-bus-port 16379
|
||||||
|
lifecycle:
|
||||||
|
postStart:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -lc
|
||||||
|
- |
|
||||||
|
set -e
|
||||||
|
for i in $(seq 1 60); do
|
||||||
|
redis-cli -h 127.0.0.1 -p 6379 ping >/dev/null 2>&1 && break
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# If cluster is already initialized, do nothing.
|
||||||
|
if redis-cli -h 127.0.0.1 -p 6379 cluster info 2>/dev/null | grep -q 'cluster_slots_assigned:16384'; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Redis 7+ supports CLUSTER ADDSLOTSRANGE.
|
||||||
|
redis-cli -h 127.0.0.1 -p 6379 cluster addslotsrange 0 16383 || true
|
||||||
|
|||||||
Reference in New Issue
Block a user