Skip to content

Commit

Permalink
fix: exporter can not connect to redis when enable tls (#902)
Browse files Browse the repository at this point in the history
Signed-off-by: wkd-woo <[email protected]>
  • Loading branch information
wkd-woo authored Apr 29, 2024
1 parent 4c7b570 commit 9cd2ae9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion k8sutils/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ func enableRedisMonitoring(params containerParameters) corev1.Container {

func getExporterEnvironmentVariables(params containerParameters) []corev1.EnvVar {
var envVars []corev1.EnvVar
redisHost := "redis://localhost:"
if params.TLSConfig != nil {
envVars = append(envVars, corev1.EnvVar{
Name: "REDIS_EXPORTER_TLS_CLIENT_KEY_FILE",
Expand All @@ -508,6 +509,7 @@ func getExporterEnvironmentVariables(params containerParameters) []corev1.EnvVar
Name: "REDIS_EXPORTER_SKIP_TLS_VERIFICATION",
Value: "true",
})
redisHost = "rediss://localhost:"
}
if params.RedisExporterPort != nil {
envVars = append(envVars, corev1.EnvVar{
Expand All @@ -518,7 +520,7 @@ func getExporterEnvironmentVariables(params containerParameters) []corev1.EnvVar
if params.Port != nil {
envVars = append(envVars, corev1.EnvVar{
Name: "REDIS_ADDR",
Value: fmt.Sprintf("redis://localhost:%d", *params.Port),
Value: redisHost + strconv.Itoa(*params.Port),
})
}
if params.EnabledPassword != nil && *params.EnabledPassword {
Expand Down

0 comments on commit 9cd2ae9

Please sign in to comment.