Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Add init script to fix wrong IP address in nodes.conf
Browse files Browse the repository at this point in the history
As described in redis/redis#4645,
when a node comes up with a new IP address, it does not update
its own IP address in nodes.conf. To fix this, an entrypoint
script updates the IP address before starting Redis Server.

Fixes #6
  • Loading branch information
sanderploegsma committed Aug 22, 2018
1 parent 8314430 commit 195bcef
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions redis-cluster.yml
Expand Up @@ -6,6 +6,18 @@ metadata:
labels:
app: redis-cluster
data:
fix-ip.sh: |
#!/bin/sh
CLUSTER_CONFIG="/data/nodes.conf"
if [ -f ${CLUSTER_CONFIG} ]; then
if [ -z "${POD_IP}" ]; then
echo "Unable to determine Pod IP address!"
exit 1
fi
echo "Updating my IP to ${POD_IP} in ${CLUSTER_CONFIG}"
sed -i.bak -e '/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${POD_IP}/' ${CLUSTER_CONFIG}
fi
exec "$@"
redis.conf: |+
cluster-enabled yes
cluster-require-full-coverage no
Expand Down Expand Up @@ -58,8 +70,7 @@ spec:
name: client
- containerPort: 16379
name: gossip
command: ["redis-server"]
args: ["/conf/redis.conf"]
command: ["/conf/fix-ip.sh", "redis-server", "/conf/redis.conf"]
readinessProbe:
exec:
command:
Expand All @@ -76,6 +87,11 @@ spec:
- "redis-cli -h $(hostname) ping"
initialDelaySeconds: 20
periodSeconds: 3
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
volumeMounts:
- name: conf
mountPath: /conf
Expand All @@ -87,9 +103,7 @@ spec:
- name: conf
configMap:
name: redis-cluster
items:
- key: redis.conf
path: redis.conf
defaultMode: 0755
volumeClaimTemplates:
- metadata:
name: data
Expand Down

0 comments on commit 195bcef

Please sign in to comment.