diff --git a/pkg/lorry/engines/redis/manager.go b/pkg/lorry/engines/redis/manager.go index 70a3610245d..e37bded9ac3 100644 --- a/pkg/lorry/engines/redis/manager.go +++ b/pkg/lorry/engines/redis/manager.go @@ -21,6 +21,7 @@ package redis import ( "context" + "fmt" "strings" "time" @@ -64,6 +65,10 @@ func NewManager(properties engines.Properties) (engines.DBManager, error) { redisPasswd = viper.GetString(constant.KBEnvServicePassword) } + if viper.IsSet(constant.KBEnvServicePort) { + properties["redisHost"] = fmt.Sprintf("127.0.0.1:%s", viper.GetString(constant.KBEnvServicePort)) + } + managerBase, err := engines.NewDBManagerBase(logger) if err != nil { return nil, err diff --git a/pkg/lorry/engines/redis/redis.go b/pkg/lorry/engines/redis/redis.go index 39e8b8a8c91..bf8a5ff76ec 100644 --- a/pkg/lorry/engines/redis/redis.go +++ b/pkg/lorry/engines/redis/redis.go @@ -145,10 +145,11 @@ func newClient(s *Settings) redis.UniversalClient { } func newSentinelClient(s *Settings, clusterCompName string) *redis.SentinelClient { - // TODO: use headless service directly - sentinelEnv := fmt.Sprintf("%s_SENTINEL_SERVICE", strings.ToUpper(strings.Join(strings.Split(clusterCompName, "-"), "_"))) - sentinelHost := viper.GetString(fmt.Sprintf("%s_HOST", sentinelEnv)) - sentinelPort := viper.GetString(fmt.Sprintf("%s_PORT", sentinelEnv)) + sentinelHost := fmt.Sprintf("%s-sentinel-headless", clusterCompName) + sentinelPort := "26379" + if viper.IsSet("REDIS_SENTINEL_HOST_NETWORK_PORT") { + sentinelPort = viper.GetString("REDIS_SENTINEL_HOST_NETWORK_PORT") + } opt := &redis.Options{ DB: s.DB,