You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: charts/redis/templates/statefulset.yaml
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ spec:
78
78
79
79
# Check if any sentinel is already running and knows the master
80
80
for i in $(seq 0 {{ sub .Values.replicaCount 1 }}); do
81
-
SENTINEL_HOST="{{ include "redis.fullname" . }}-${i}.{{ include "redis.fullname" . }}-headless"
81
+
SENTINEL_HOST="{{ include "redis.fullname" . }}-${i}.{{ include "redis.fullname" . }}-headless.{{ include "cloudpirates.namespace" . }}.svc.{{ .Values.clusterDomain }}"
82
82
MASTER_INFO=$(redis-cli -h "${SENTINEL_HOST}" -p {{ .Values.sentinel.port }} {{- if .Values.auth.sentinel }} -a "${REDIS_PASSWORD}"{{- end }} sentinel get-master-addr-by-name {{ .Values.sentinel.masterName }} 2>/dev/null | head -1 || echo "")
83
83
if [ -n "$MASTER_INFO" ] && [ "$MASTER_INFO" != "Could not connect" ]; then
84
84
CURRENT_MASTER="$MASTER_INFO"
@@ -92,7 +92,7 @@ spec:
92
92
if [ "$SENTINEL_FOUND" = true ] && [ -n "$CURRENT_MASTER" ]; then
93
93
# Sentinel knows the master - configure accordingly
94
94
MY_HOSTNAME=$(hostname)
95
-
MY_HOSTNAME_FQDN="${MY_HOSTNAME}.{{ include "redis.fullname" . }}-headless"
95
+
MY_HOSTNAME_FQDN="${MY_HOSTNAME}.{{ include "redis.fullname" . }}-headless.{{ include "cloudpirates.namespace" . }}.svc.{{ .Values.clusterDomain }}"
96
96
MY_IP=$(hostname -i)
97
97
98
98
# Check if I am the master by hostname or IP
@@ -110,7 +110,7 @@ spec:
110
110
if [ "$POD_ORDINAL" != "0" ]; then
111
111
echo "Bootstrap mode: configuring as replica of pod-0"
112
112
# Use hostname-based replication for better resilience
113
-
MASTER_HOSTNAME="{{ include "redis.fullname" . }}-0.{{ include "redis.fullname" . }}-headless"
113
+
MASTER_HOSTNAME="{{ include "redis.fullname" . }}-0.{{ include "redis.fullname" . }}-headless.{{ include "cloudpirates.namespace" . }}.svc.{{ .Values.clusterDomain }}"
114
114
echo "replicaof $MASTER_HOSTNAME {{ if .Values.tls.enabled }}{{ .Values.tls.port }}{{ else }}{{ .Values.service.port }}{{ end }}" >> /tmp/redis.conf
115
115
echo "Bootstrap replica using pod-0 hostname: $MASTER_HOSTNAME"
echo "slave-announce-port {{ if .Values.tls.enabled }}{{ .Values.tls.port }}{{ else }}{{ .Values.service.port }}{{ end }}" >> /tmp/redis.conf
149
149
{{- else }}
150
-
echo "Using hostname: ${HOSTNAME}.{{ include "redis.fullname" . }}-headless"
151
-
echo "replica-announce-ip ${HOSTNAME}.{{ include "redis.fullname" . }}-headless" >> /tmp/redis.conf
150
+
echo "Using hostname: ${HOSTNAME}.{{ include "redis.fullname" . }}-headless.{{ include "cloudpirates.namespace" . }}.svc.{{ .Values.clusterDomain }}"
151
+
echo "replica-announce-ip ${HOSTNAME}.{{ include "redis.fullname" . }}-headless.{{ include "cloudpirates.namespace" . }}.svc.{{ .Values.clusterDomain }}" >> /tmp/redis.conf
152
152
echo "replica-announce-port {{ if .Values.tls.enabled }}{{ .Values.tls.port }}{{ else }}{{ .Values.service.port }}{{ end }}" >> /tmp/redis.conf
153
-
echo "slave-announce-ip ${HOSTNAME}.{{ include "redis.fullname" . }}-headless" >> /tmp/redis.conf
153
+
echo "slave-announce-ip ${HOSTNAME}.{{ include "redis.fullname" . }}-headless.{{ include "cloudpirates.namespace" . }}.svc.{{ .Values.clusterDomain }}" >> /tmp/redis.conf
154
154
echo "slave-announce-port {{ if .Values.tls.enabled }}{{ .Values.tls.port }}{{ else }}{{ .Values.service.port }}{{ end }}" >> /tmp/redis.conf
155
155
{{- end }}
156
156
@@ -161,7 +161,7 @@ spec:
161
161
# Replication without Sentinel: pod-0 is always master, others are replicas
162
162
if [ "$POD_ORDINAL" != "0" ]; then
163
163
echo "Configuring as replica of pod-0 (master)"
164
-
MASTER_HOSTNAME="{{ include "redis.fullname" . }}-0.{{ include "redis.fullname" . }}-headless"
164
+
MASTER_HOSTNAME="{{ include "redis.fullname" . }}-0.{{ include "redis.fullname" . }}-headless.{{ include "cloudpirates.namespace" . }}.svc.{{ .Values.clusterDomain }}"
165
165
echo "replicaof $MASTER_HOSTNAME {{ if .Values.tls.enabled }}{{ .Values.tls.port }}{{ else }}{{ .Values.service.port }}{{ end }}" >> /tmp/redis.conf
echo "Checking existing Sentinels for current master..."
395
395
for i in $(seq 0 {{ sub .Values.replicaCount 1 }}); do
396
396
if [ "$i" != "$POD_ORDINAL" ]; then
397
-
SENTINEL_HOST="{{ include "redis.fullname" . }}-${i}.{{ include "redis.fullname" . }}-headless"
397
+
SENTINEL_HOST="{{ include "redis.fullname" . }}-${i}.{{ include "redis.fullname" . }}-headless.{{ include "cloudpirates.namespace" . }}.svc.{{ .Values.clusterDomain }}"
398
398
EXISTING_MASTER=$(redis-cli -h "${SENTINEL_HOST}" -p {{ .Values.sentinel.port }} {{- if .Values.auth.sentinel }} -a "${REDIS_PASSWORD}"{{- end }} sentinel get-master-addr-by-name {{ .Values.sentinel.masterName }} 2>/dev/null | head -1 || echo "")
399
399
if [ -n "$EXISTING_MASTER" ] && [ "$EXISTING_MASTER" != "Could not connect" ]; then
400
400
MASTER_HOST="$EXISTING_MASTER"
@@ -469,7 +469,7 @@ spec:
469
469
sentinel_link_buffer_size 32768
470
470
# Allow sentinels to discover each other
471
471
{{ if .Values.sentinel.config.announceHostnames }}
472
-
sentinel announce-ip ${HOSTNAME}.{{ include "redis.fullname" . }}-headless
472
+
sentinel announce-ip ${HOSTNAME}.{{ include "redis.fullname" . }}-headless.{{ include "cloudpirates.namespace" . }}.svc.{{ .Values.clusterDomain }}
473
473
{{- else }}
474
474
sentinel announce-ip ${SENTINEL_IP}
475
475
{{- end }}
@@ -481,7 +481,7 @@ spec:
481
481
# Add known sentinels to help with discovery (using hostnames for resilience)
482
482
for i in $(seq 0 {{ sub .Values.replicaCount 1 }}); do
483
483
if [ "$i" != "$POD_ORDINAL" ]; then
484
-
SENTINEL_HOST="{{ include "redis.fullname" . }}-${i}.{{ include "redis.fullname" . }}-headless"
484
+
SENTINEL_HOST="{{ include "redis.fullname" . }}-${i}.{{ include "redis.fullname" . }}-headless.{{ include "cloudpirates.namespace" . }}.svc.{{ .Values.clusterDomain }}"
485
485
# Test if the host is resolvable before adding
486
486
if getent hosts "$SENTINEL_HOST" >/dev/null 2>&1; then
487
487
SENTINEL_IP=$(getent hosts "$SENTINEL_HOST" | awk '{print $1}' | head -1)
0 commit comments