diff --git a/bitnami/redis/Chart.yaml b/bitnami/redis/Chart.yaml
index b4d817f32922f5..76c094ce2a6dee 100644
--- a/bitnami/redis/Chart.yaml
+++ b/bitnami/redis/Chart.yaml
@@ -25,4 +25,4 @@ name: redis
sources:
- https://github.com/bitnami/bitnami-docker-redis
- http://redis.io/
-version: 12.7.6
+version: 12.7.7
diff --git a/bitnami/redis/README.md b/bitnami/redis/README.md
index f3f259b0a3d17d..052b4b5a46db8e 100644
--- a/bitnami/redis/README.md
+++ b/bitnami/redis/README.md
@@ -258,6 +258,7 @@ The following table lists the configurable parameters of the RedisTM
| `sentinel.failoverTimeout` | Timeout for performing a election failover | `18000` |
| `sentinel.parallelSyncs` | Number of parallel syncs in the cluster | `1` |
| `sentinel.port` | RedisTM Sentinel port | `26379` |
+| `sentinel.cleanDelaySeconds` | Delay seconds before issuing the the cleaning in the next node | `5` |
| `sentinel.configmap` | Additional RedisTM configuration for the sentinel nodes (this value is evaluated as a template) | `nil` |
| `sentinel.staticID` | Enable static IDs for sentinel replicas (If disabled IDs will be randomly generated on startup) | `false` |
| `sentinel.service.type` | Kubernetes Service type (redis sentinel) | `ClusterIP` |
diff --git a/bitnami/redis/templates/configmap-scripts.yaml b/bitnami/redis/templates/configmap-scripts.yaml
index 4d8f7c6c3bdd53..377fbea90e9b71 100644
--- a/bitnami/redis/templates/configmap-scripts.yaml
+++ b/bitnami/redis/templates/configmap-scripts.yaml
@@ -12,20 +12,28 @@ data:
{{- if and .Values.cluster.enabled .Values.sentinel.enabled }}
start-node.sh: |
#!/bin/bash
- is_boolean_yes() {
- local -r bool="${1:-}"
- # comparison is performed without regard to the case of alphabetic characters
- shopt -s nocasematch
- if [[ "$bool" = 1 || "$bool" =~ ^(yes|true)$ ]]; then
- true
- else
- false
- fi
+
+ . /opt/bitnami/scripts/libos.sh
+ . /opt/bitnami/scripts/liblog.sh
+ . /opt/bitnami/scripts/libvalidations.sh
+
+ not_exists_dns_entry() {
+ myip=$(hostname -i)
+
+ if [[ -z "$(getent ahosts "$HEADLESS_SERVICE" | grep "^${myip}" )" ]]; then
+ warn "$HEADLESS_SERVICE does not contain the IP of this pod: ${myip}"
+ return 1
+ fi
+ info "$HEADLESS_SERVICE has my IP: ${myip}"
+ return 0
}
HEADLESS_SERVICE="{{ template "redis.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
REDIS_SERVICE="{{ template "redis.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
+ # Waits for DNS to add this ip to the service DNS entry
+ retry_while not_exists_dns_entry
+
export REDIS_REPLICATION_MODE="slave"
if [[ -z "$(getent ahosts "$HEADLESS_SERVICE" | grep -v "^$(hostname -i) ")" ]]; then
export REDIS_REPLICATION_MODE="master"
@@ -137,25 +145,11 @@ data:
start-sentinel.sh: |
#!/bin/bash
- replace_in_file() {
- local filename="${1:?filename is required}"
- local match_regex="${2:?match regex is required}"
- local substitute_regex="${3:?substitute regex is required}"
- local posix_regex=${4:-true}
-
- local result
-
- # We should avoid using 'sed in-place' substitutions
- # 1) They are not compatible with files mounted from ConfigMap(s)
- # 2) We found incompatibility issues with Debian10 and "in-place" substitutions
- del=$'\001' # Use a non-printable character as a 'sed' delimiter to avoid issues
- if [[ $posix_regex = true ]]; then
- result="$(sed -E "s${del}${match_regex}${del}${substitute_regex}${del}g" "$filename")"
- else
- result="$(sed "s${del}${match_regex}${del}${substitute_regex}${del}g" "$filename")"
- fi
- echo "$result" > "$filename"
- }
+
+ . /opt/bitnami/scripts/libos.sh
+ . /opt/bitnami/scripts/libvalidations.sh
+ . /opt/bitnami/scripts/libfile.sh
+
sentinel_conf_set() {
local -r key="${1:?missing key}"
local value="${2:-}"
@@ -171,19 +165,19 @@ data:
sentinel_conf_add() {
echo $'\n'"$@" >> "/opt/bitnami/redis-sentinel/etc/sentinel.conf"
}
- is_boolean_yes() {
- local -r bool="${1:-}"
- # comparison is performed without regard to the case of alphabetic characters
- shopt -s nocasematch
- if [[ "$bool" = 1 || "$bool" =~ ^(yes|true)$ ]]; then
- true
- else
- false
- fi
- }
host_id() {
echo "$1" | openssl sha1 | awk '{print $2}'
}
+ not_exists_dns_entry() {
+ myip=$(hostname -i)
+
+ if [[ -z "$(getent ahosts "$HEADLESS_SERVICE" | grep "^${myip}" )" ]]; then
+ warn "$HEADLESS_SERVICE does not contain the IP of this pod: ${myip}"
+ return 1
+ fi
+ info "$HEADLESS_SERVICE has my IP: ${myip}"
+ return 0
+ }
HEADLESS_SERVICE="{{ template "redis.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
REDIS_SERVICE="{{ template "redis.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
@@ -207,10 +201,26 @@ data:
fi
export REDIS_REPLICATION_MODE="slave"
- if [[ -z "$(getent ahosts "$HEADLESS_SERVICE" | grep -v "^$(hostname -i) ")" ]]; then
+
+ # Waits for DNS to add this ip to the service DNS entry
+ retry_while not_exists_dns_entry
+
+ if [[ -z "$(getent ahosts "$HEADLESS_SERVICE" | grep -v "^$(hostname -i)")" ]]; then
export REDIS_REPLICATION_MODE="master"
fi
+ # Clean sentineles from the current sentinel nodes
+ for node in $( getent ahosts "$HEADLESS_SERVICE" | grep -v "^$(hostname -i)" | cut -f 1 -d ' ' | uniq ); do
+ info "Cleaning sentinels in sentinel node: $node"
+ if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
+ redis-cli {{- if .Values.usePassword }} -a $REDIS_PASSWORD {{- end }} -h $node -p {{ .Values.sentinel.port }} --tls --cert ${REDIS_SENTINEL_TLS_CERT_FILE} --key ${REDIS_SENTINEL_TLS_KEY_FILE} --cacert ${REDIS_SENTINEL_TLS_CA_FILE} sentinel reset "*"
+ else
+ redis-cli {{- if .Values.usePassword }} -a $REDIS_PASSWORD {{- end }} -h $node -p {{ .Values.sentinel.port }} sentinel reset "*"
+ fi
+ sleep {{ .Values.sentinel.cleanDelaySeconds }}
+ done
+ info "Sentinels clean up done"
+
if [[ "$REDIS_REPLICATION_MODE" == "master" ]]; then
REDIS_MASTER_HOST="$(hostname -i)"
REDIS_MASTER_PORT_NUMBER="{{ .Values.redisPort }}"
diff --git a/bitnami/redis/values.yaml b/bitnami/redis/values.yaml
index bcca75eb5cc817..fac31158f366f8 100644
--- a/bitnami/redis/values.yaml
+++ b/bitnami/redis/values.yaml
@@ -78,10 +78,17 @@ sentinel:
masterSet: mymaster
initialCheckTimeout: 5
quorum: 2
- downAfterMilliseconds: 60000
+ downAfterMilliseconds: 20000
failoverTimeout: 18000
parallelSyncs: 1
port: 26379
+
+ ## Delay seconds when cleaning nodes IPs
+ ## When starting it will clean the sentiles IP (RESET "*") in all the nodes
+ ## This is the delay time before sending the command to the next node
+ ##
+ cleanDelaySeconds: 5
+
## Additional Redis(TM) configuration for the sentinel nodes
## ref: https://redis.io/topics/config
##