From 8354fed2a243c3943ff46d78ed573578fb3b99d3 Mon Sep 17 00:00:00 2001 From: yangw Date: Wed, 19 Jun 2024 20:58:01 +0800 Subject: [PATCH] fix: add default port to enable `SENTINEL_PORT` environment (#999) * fix: add default port to enable `SENTINEL_PORT` environment Signed-off-by: drivebyer * fix test Signed-off-by: drivebyer --------- Signed-off-by: drivebyer Signed-off-by: Matt Robinson --- k8sutils/redis-replication.go | 2 +- k8sutils/redis-sentinel.go | 1 + k8sutils/redis-sentinel_test.go | 1 + k8sutils/redis-standalone.go | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/k8sutils/redis-replication.go b/k8sutils/redis-replication.go index 5610aa17f..545d9b079 100644 --- a/k8sutils/redis-replication.go +++ b/k8sutils/redis-replication.go @@ -125,7 +125,7 @@ func generateRedisReplicationContainerParams(cr *redisv1beta2.RedisReplication) ImagePullPolicy: cr.Spec.KubernetesConfig.ImagePullPolicy, Resources: cr.Spec.KubernetesConfig.Resources, SecurityContext: cr.Spec.SecurityContext, - Port: ptr.To(6379), + Port: ptr.To(redisPort), } if cr.Spec.EnvVars != nil { containerProp.EnvVars = cr.Spec.EnvVars diff --git a/k8sutils/redis-sentinel.go b/k8sutils/redis-sentinel.go index 6f83d37bc..1a985b1eb 100644 --- a/k8sutils/redis-sentinel.go +++ b/k8sutils/redis-sentinel.go @@ -152,6 +152,7 @@ func generateRedisSentinelContainerParams(ctx context.Context, client kubernetes ImagePullPolicy: cr.Spec.KubernetesConfig.ImagePullPolicy, Resources: cr.Spec.KubernetesConfig.Resources, SecurityContext: cr.Spec.SecurityContext, + Port: ptr.To(sentinelPort), AdditionalEnvVariable: getSentinelEnvVariable(ctx, client, logger, cr, dcl), } if cr.Spec.EnvVars != nil { diff --git a/k8sutils/redis-sentinel_test.go b/k8sutils/redis-sentinel_test.go index eb19e5d1b..1eae1a4a1 100644 --- a/k8sutils/redis-sentinel_test.go +++ b/k8sutils/redis-sentinel_test.go @@ -176,6 +176,7 @@ func Test_generateRedisSentinelContainerParams(t *testing.T) { Value: "custom_value_2", }, }, + Port: ptr.To(26379), AdditionalVolume: []v1.Volume{ { Name: "redis-config", diff --git a/k8sutils/redis-standalone.go b/k8sutils/redis-standalone.go index 65bcd9f7d..b53cff6ff 100644 --- a/k8sutils/redis-standalone.go +++ b/k8sutils/redis-standalone.go @@ -121,7 +121,7 @@ func generateRedisStandaloneContainerParams(cr *redisv1beta2.Redis) containerPar ImagePullPolicy: cr.Spec.KubernetesConfig.ImagePullPolicy, Resources: cr.Spec.KubernetesConfig.Resources, SecurityContext: cr.Spec.SecurityContext, - Port: ptr.To(6379), + Port: ptr.To(redisPort), } if cr.Spec.EnvVars != nil {