From f0dff72e7495a58aa3a0bbf914f3d067ed63b081 Mon Sep 17 00:00:00 2001 From: dingben Date: Mon, 20 May 2024 14:50:09 +0800 Subject: [PATCH] feat: ycsb support multiple addr (#70) --- api/v1alpha1/ycsb_types.go | 1 + config/crd/bases/benchmark.apecloud.io_ycsbs.yaml | 2 ++ deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml | 2 ++ deploy/helm/values.yaml | 6 +++--- internal/controller/ycsb_job.go | 7 ++++++- pkg/constants/env.go | 4 ++-- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/api/v1alpha1/ycsb_types.go b/api/v1alpha1/ycsb_types.go index a151caa..03cfd2c 100644 --- a/api/v1alpha1/ycsb_types.go +++ b/api/v1alpha1/ycsb_types.go @@ -107,6 +107,7 @@ type YcsbSpec struct { MasterName string `json:"masterName,omitempty"` RedisSentinelUsername string `json:"redisSentinelUsername,omitempty"` RedisSentinelPassword string `json:"redisSentinelPassword,omitempty"` + RedisAddr string `json:"redisAddr,omitempty"` BenchCommon `json:",inline"` } diff --git a/config/crd/bases/benchmark.apecloud.io_ycsbs.yaml b/config/crd/bases/benchmark.apecloud.io_ycsbs.yaml index e62b183..a2403e8 100644 --- a/config/crd/bases/benchmark.apecloud.io_ycsbs.yaml +++ b/config/crd/bases/benchmark.apecloud.io_ycsbs.yaml @@ -75,6 +75,8 @@ spec: default: 10000 minimum: 1 type: integer + redisAddr: + type: string redisMode: type: string redisSentinelPassword: diff --git a/deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml b/deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml index e62b183..a2403e8 100644 --- a/deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml +++ b/deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml @@ -75,6 +75,8 @@ spec: default: 10000 minimum: 1 type: integer + redisAddr: + type: string redisMode: type: string redisSentinelPassword: diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 268a028..95dd701 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -9,7 +9,7 @@ image: pullPolicy: IfNotPresent registry: registry.cn-hangzhou.aliyuncs.com # Overrides the image tag whose default is the chart appVersion. - tag: "0.0.8" + tag: "0.0.9" imagePullSecrets: [] nameOverride: "" @@ -91,5 +91,5 @@ kubebenchImages: ycsb: "registry.cn-hangzhou.aliyuncs.com/apecloud/go-ycsb:latest" fio: "registry.cn-hangzhou.aliyuncs.com/apecloud/fio:latest" redisbench: "registry.cn-hangzhou.aliyuncs.com/apecloud/redis:7.0.5" - exporter: "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.6" - tools: "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.6" \ No newline at end of file + exporter: "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.9" + tools: "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.9" \ No newline at end of file diff --git a/internal/controller/ycsb_job.go b/internal/controller/ycsb_job.go index f71740a..a5e37a4 100644 --- a/internal/controller/ycsb_job.go +++ b/internal/controller/ycsb_job.go @@ -197,7 +197,12 @@ func NewYcsbMysqlParams(cr *v1alpha1.Ycsb) string { } func NewYcsbRedisParams(cr *v1alpha1.Ycsb) string { - result := fmt.Sprintf("-p redis.addr=%s", fmt.Sprintf("%s:%d", cr.Spec.Target.Host, cr.Spec.Target.Port)) + result := "" + if cr.Spec.RedisAddr != "" { + result = fmt.Sprintf("-p redis.addr='%s'", cr.Spec.RedisAddr) + } else { + result = fmt.Sprintf("-p redis.addr='%s'", fmt.Sprintf("%s:%d", cr.Spec.Target.Host, cr.Spec.Target.Port)) + } if cr.Spec.Target.User != "" { result = fmt.Sprintf("%s -p redis.username=%s", result, cr.Spec.Target.User) } diff --git a/pkg/constants/env.go b/pkg/constants/env.go index 7953265..8194ab7 100644 --- a/pkg/constants/env.go +++ b/pkg/constants/env.go @@ -28,8 +28,8 @@ func init() { viper.SetDefault(KubebenchEnvYcsb, "registry.cn-hangzhou.aliyuncs.com/apecloud/go-ycsb:latest") viper.SetDefault(KubebenchEnvFio, "registry.cn-hangzhou.aliyuncs.com/apecloud/fio:latest") viper.SetDefault(KubebenchEnvRedisBench, "registry.cn-hangzhou.aliyuncs.com/apecloud/redis:7.0.5") - viper.SetDefault(KubebenchExporter, "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.6") - viper.SetDefault(KubebenchTools, "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.6") + viper.SetDefault(KubebenchExporter, "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.9") + viper.SetDefault(KubebenchTools, "registry.cn-hangzhou.aliyuncs.com/apecloud/kubebench:0.0.9") } // GetBenchmarkImage get benchmark image