Skip to content

Commit

Permalink
chore: optimize redis default acl and sentinel startup script (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Rookie authored Nov 27, 2023
1 parent d7030ac commit 16479f8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion addons/redis/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "Redis is an in-memory database that persists on disk. The data mod

type: application

version: 0.7.0
version: 0.8.0

appVersion: "7.0.6"

Expand Down
10 changes: 7 additions & 3 deletions addons/redis/scripts/redis-sentinel-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ set -ex
{{- $primary_svc := printf "%s-%s.%s.svc" $clusterName $redis_component.name $namespace }}
echo "Waiting for redis service {{ $primary_svc }} to be ready..."
if [ ! -z "$REDIS_DEFAULT_PASSWORD" ]; then
until redis-cli -h {{ $primary_svc }} -p 6379 -a $REDIS_DEFAULT_PASSWORD ping; do sleep 1; done
timeout 300 sh -c 'until redis-cli -h {{ $primary_svc }} -p 6379 -a $REDIS_DEFAULT_PASSWORD ping; do sleep 2; done'
else
until redis-cli -h {{ $primary_svc }} -p 6379 ping; do sleep 1; done
timeout 300 sh -c 'until redis-cli -h {{ $primary_svc }} -p 6379 ping; do sleep 1; done'
fi
echo "redis service ready, Starting sentinel..."
if [ $? -ne 0 ]; then
echo "Redis service is not ready, exiting..."
exit 1
fi
echo "Redis service ready, Starting sentinel..."
echo "sentinel announce-ip $KB_POD_FQDN" >> /etc/sentinel/redis-sentinel.conf
exec redis-server /etc/sentinel/redis-sentinel.conf --sentinel
echo "Start sentinel succeeded!"
2 changes: 1 addition & 1 deletion addons/redis/scripts/redis-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if [ ! -z "$REDIS_SENTINEL_PASSWORD" ]; then
fi
if [ ! -z "$REDIS_DEFAULT_PASSWORD" ]; then
echo "protected-mode yes" >> /etc/redis/redis.conf
echo "user default on allcommands allkeys >$REDIS_DEFAULT_PASSWORD" >> /data/users.acl
echo "user default on >$REDIS_DEFAULT_PASSWORD ~* &* +@all " >> /data/users.acl
else
echo "protected-mode no" >> /etc/redis/redis.conf
fi
Expand Down
2 changes: 2 additions & 0 deletions addons/redis/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ spec:
- name: redis-sentinel
workloadType: Stateful
characterType: redis
statefulSpec:
updateStrategy: BestEffortParallel
service:
ports:
- name: redis-sentinel
Expand Down

0 comments on commit 16479f8

Please sign in to comment.