Skip to content

Commit

Permalink
Merge pull request #235 from teamon/fix-readiness-auth
Browse files Browse the repository at this point in the history
Add REDIS_PASSWORD to server container and use it for readiness probe
  • Loading branch information
chusAlvarez authored Feb 5, 2020
2 parents 09f3dc8 + bef90f3 commit 11131c8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions operator/redisfailover/service/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ func generateRedisReadinessConfigMap(rf *redisfailoverv1.RedisFailover, labels m
}
check_slave(){
in_sync=$(redis-cli info replication | grep $IN_SYNC | tr -d "\r" | tr -d "\n")
no_master=$(redis-cli info replication | grep $NO_MASTER | tr -d "\r" | tr -d "\n")
in_sync=$(redis-cli -a "${REDIS_PASSWORD}" info replication | grep $IN_SYNC | tr -d "\r" | tr -d "\n")
no_master=$(redis-cli -a "${REDIS_PASSWORD}" info replication | grep $NO_MASTER | tr -d "\r" | tr -d "\n")
if [ -z "$in_sync" ] && [ -z "$no_master" ]; then
exit 0
Expand All @@ -206,7 +206,7 @@ func generateRedisReadinessConfigMap(rf *redisfailoverv1.RedisFailover, labels m
exit 1
}
role=$(redis-cli info replication | grep $ROLE | tr -d "\r" | tr -d "\n")
role=$(redis-cli -a "${REDIS_PASSWORD}" info replication | grep $ROLE | tr -d "\r" | tr -d "\n")
case $role in
$ROLE_MASTER)
Expand Down Expand Up @@ -340,6 +340,20 @@ func generateRedisStatefulSet(rf *redisfailoverv1.RedisFailover, labels map[stri
ss.Spec.Template.Spec.Containers = append(ss.Spec.Template.Spec.Containers, exporter)
}

if rf.Spec.Auth.SecretPath != "" {
ss.Spec.Template.Spec.Containers[0].Env = append(ss.Spec.Template.Spec.Containers[0].Env, corev1.EnvVar{
Name: "REDIS_PASSWORD",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: rf.Spec.Auth.SecretPath,
},
Key: "password",
},
},
})
}

return ss
}

Expand Down

0 comments on commit 11131c8

Please sign in to comment.