Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bitnami/redis/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 21.2.16 (2025-08-07)
## 21.2.17 (2025-08-07)

* [bitnami/redis] :zap: :arrow_up: Update dependency references ([#35523](https://github.com/bitnami/charts/pull/35523))
* [bitnami/redis] Add support to redis master service with useHostnames false ([#35536](https://github.com/bitnami/charts/pull/35536))

## <small>21.2.16 (2025-08-07)</small>

* [bitnami/redis] :zap: :arrow_up: Update dependency references (#35523) ([f967ba4](https://github.com/bitnami/charts/commit/f967ba4360f0c206b19a1d3e42f18b0fedc7cce7)), closes [#35523](https://github.com/bitnami/charts/issues/35523)

## <small>21.2.15 (2025-08-07)</small>

Expand Down
2 changes: 1 addition & 1 deletion bitnami/redis/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ maintainers:
name: redis
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/redis
version: 21.2.16
version: 21.2.17
87 changes: 75 additions & 12 deletions bitnami/redis/templates/scripts-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,11 @@ data:
{{- if or .Values.sentinel.masterService.enabled .Values.sentinel.service.createMaster }}
if [[ "${REDIS_REPLICATION_MODE}" == "master" ]]; then
# Add isMaster label to master node for master service
{{- if .Values.useHostnames }}
echo "${REDIS_MASTER_HOST/.*}" > /etc/shared/current
{{- else }}
echo "${REDIS_MASTER_HOST}" > /etc/shared/current
{{- end }}
fi
{{- end }}

Expand Down Expand Up @@ -807,12 +811,17 @@ data:
fi

{{- if or .Values.sentinel.masterService.enabled .Values.sentinel.service.createMaster }}
push-master-label.sh: |
#!/bin/bash
# https://download.redis.io/redis-stable/sentinel.conf

echo "${6/.*}" > /etc/shared/current
echo "${4/.*}" > /etc/shared/previous
push-master-label.sh: |
#!/bin/bash
# https://download.redis.io/redis-stable/sentinel.conf

{{- if .Values.useHostnames }}
echo "${6/.*}" > /etc/shared/current
echo "${4/.*}" > /etc/shared/previous
{{- else }}
echo "$6" > /etc/shared/current
echo "$4" > /etc/shared/previous
{{- end }}
Comment on lines +822 to +832
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct me if I'm wrong but this change in the indentation is unexpected:

Suggested change
push-master-label.sh: |
#!/bin/bash
# https://download.redis.io/redis-stable/sentinel.conf
{{- if .Values.useHostnames }}
echo "${6/.*}" > /etc/shared/current
echo "${4/.*}" > /etc/shared/previous
{{- else }}
echo "$6" > /etc/shared/current
echo "$4" > /etc/shared/previous
{{- end }}
push-master-label.sh: |
#!/bin/bash
# https://download.redis.io/redis-stable/sentinel.conf
{{- if .Values.useHostnames }}
echo "${6/.*}" > /etc/shared/current
echo "${4/.*}" > /etc/shared/previous
{{- else }}
echo "$6" > /etc/shared/current
echo "$4" > /etc/shared/previous
{{- end }}

{{- end }}
{{- else }}
start-master.sh: |
Expand Down Expand Up @@ -1000,25 +1009,79 @@ metadata:
data:
update-master-label.sh: |
#!/bin/bash
set -euo pipefail

LOCK_FILE="/etc/shared/update-master-label.lock"

{{- if eq .Values.useHostnames false }}
resolve_pod() {
local pod_ip="$1"
kubectl get pods -o custom-columns=":metadata.name" --field-selector=status.podIP="$pod_ip" --no-headers 2>/dev/null | head -n1
}
{{- end }}

flock -n "$LOCK_FILE" bash <<'EOF'
while true; do
while [ ! -f "/etc/shared/current" ] && [ ! -f "/etc/shared/terminate" ]; do
sleep 1
done

if [ -f "/etc/shared/current" ]; then
echo "new master elected, updating label(s)..."
kubectl label pod --field-selector metadata.name="$(< "/etc/shared/current")" isMaster="true" --overwrite
kubectl label pod --field-selector metadata.name="$(< "/etc/shared/current")" app.kubernetes.io/role-
current_master="$(< "/etc/shared/current")"
echo "Current master: $current_master"

if [ -f "/etc/shared/previous" ]; then
previous_master="$(< "/etc/shared/previous")"

if [ "$current_master" == "$previous_master" ]; then
echo "Master has not changed ($current_master), skipping label update and cleaning state"
rm -f /etc/shared/current /etc/shared/previous
continue
fi
fi

pod_name="$current_master"
{{- if eq .Values.useHostnames false }}
pod_name="$(resolve_pod "$current_master")"
echo "Current master IP resolved to pod $pod_name"
{{- end }}

if [ -n "$pod_name" ]; then
echo "Labeling new master pod $pod_name"
kubectl label pod --field-selector=metadata.name="$pod_name" isMaster="true" --overwrite || echo "Failed to label master"
kubectl label pod --field-selector=metadata.name="$pod_name" app.kubernetes.io/role- || echo "Failed to remove role label"
else
echo "Could not resolve pod for current master"
fi

if [ -f /etc/shared/previous ]; then
kubectl label pod --field-selector metadata.name="$(< "/etc/shared/previous")" isMaster="false" --overwrite
previous_master="$(< "/etc/shared/previous")"
echo "Previous master: $previous_master"

{{- if eq .Values.useHostnames false }}
previous_pod="$(resolve_pod "$previous_master")"
echo "Previous master IP resolved to pod $previous_pod"
{{- else }}
previous_pod="$previous_master"
{{- end }}

if [ -n "$previous_pod" ]; then
echo "Removing master label from previous pod $previous_pod"
kubectl label pod --field-selector=metadata.name="$previous_pod" isMaster="false" --overwrite || echo "Failed to remove label"
else
echo "Could not resolve pod for previous master"
fi
fi
rm "/etc/shared/current" "/etc/shared/previous"

echo "Cleaning state files"
rm -f /etc/shared/current /etc/shared/previous
fi

if [ -f "/etc/shared/terminate" ]; then
echo "received signal to terminate"
echo "Terminating on request"
rm "/etc/shared/terminate"
exit
fi
done
EOF
{{- end }}
Loading