Skip to content

Commit 82d2cba

Browse files
Merge pull request openstack-k8s-operators#486 from antonioromito/main
Add IPv6 support for Redis with pod-specific IP binding
2 parents 053afb2 + 697d811 commit 82d2cba

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

pkg/redis/statefulset.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func StatefulSet(
100100
Containers: []corev1.Container{
101101
{
102102
Image: r.Spec.ContainerImage,
103-
Command: []string{"/var/lib/operator-scripts/start_redis_replication.sh"},
103+
Command: []string{"/usr/bin/dumb-init", "--", "/var/lib/operator-scripts/start_redis_replication.sh"},
104104
Name: "redis",
105105
Env: commonEnvVars,
106106
Resources: r.Spec.Resources,
@@ -125,9 +125,8 @@ func StatefulSet(
125125
},
126126
}, {
127127
Image: r.Spec.ContainerImage,
128-
Command: []string{"/var/lib/operator-scripts/start_sentinel.sh"},
129-
130-
Name: "sentinel",
128+
Command: []string{"/usr/bin/dumb-init", "--", "/var/lib/operator-scripts/start_sentinel.sh"},
129+
Name: "sentinel",
131130
Env: append(commonEnvVars, corev1.EnvVar{
132131
Name: "SENTINEL_QUORUM",
133132
Value: strconv.Itoa((int(*r.Spec.Replicas) / 2) + 1),

templates/redis/bin/common.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ TIMEOUT=3
1010
POD_NAME=$HOSTNAME
1111
POD_FQDN=$HOSTNAME.$SVC_FQDN
1212

13+
# Extract pod IP from /etc/hosts
14+
POD_IP=$(grep "$HOSTNAME" /etc/hosts | awk '{print $1}' | head -1)
15+
1316
if test -d /var/lib/config-data/tls; then
1417
REDIS_CLI_CMD="redis-cli --tls"
1518
REDIS_CONFIG=/var/lib/redis/redis-tls.conf
@@ -35,7 +38,7 @@ function generate_configs() {
3538
cd /var/lib/config-data/default
3639
for cfg in $(find -L * -name '*.conf.in'); do
3740
log "Generating config file from template $PWD/${cfg}"
38-
sed -e "s/{ POD_FQDN }/${POD_FQDN}/" "${cfg}" > "/var/lib/config-data/generated/${cfg%.in}"
41+
sed -e "s/{ POD_FQDN }/${POD_FQDN}/g" -e "s/{ POD_IP }/${POD_IP}/g" "${cfg}" > "/var/lib/config-data/generated/${cfg%.in}"
3942
done
4043
}
4144

templates/redis/config/redis.conf.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dir /var/lib/redis
2-
bind { POD_FQDN } localhost
2+
bind { POD_IP } localhost
33
replica-announce-ip { POD_FQDN }
44
port 6379
55
tcp-backlog 511

templates/redis/config/sentinel.conf.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dir /var/lib/redis
2-
bind { POD_FQDN } localhost
2+
bind { POD_IP } localhost
33
sentinel resolve-hostnames yes
44
sentinel announce-hostnames yes
55
sentinel announce-ip { POD_FQDN }

0 commit comments

Comments
 (0)