From a2ae5d218f3463c1905b5e721696e88a37cae00b Mon Sep 17 00:00:00 2001 From: carlchen Date: Wed, 11 Dec 2024 14:45:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20cluster-manager=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AEmongodb=20replicaset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bcs-cluster-manager/conf/bcs-cluster-manager.json.template | 1 + bcs-services/bcs-cluster-manager/go.mod | 1 + bcs-services/bcs-cluster-manager/internal/app/app.go | 1 + bcs-services/bcs-cluster-manager/internal/options/options.go | 1 + bcs-services/bcs-cluster-manager/main.go | 1 + .../bcs-cluster-manager/bcs-cluster-manager.json.template | 1 + 6 files changed, 6 insertions(+) diff --git a/bcs-services/bcs-cluster-manager/conf/bcs-cluster-manager.json.template b/bcs-services/bcs-cluster-manager/conf/bcs-cluster-manager.json.template index de8e8242cd..376d990acd 100644 --- a/bcs-services/bcs-cluster-manager/conf/bcs-cluster-manager.json.template +++ b/bcs-services/bcs-cluster-manager/conf/bcs-cluster-manager.json.template @@ -1,6 +1,7 @@ { "mongo": { "address": "${bcsClusterManagerMongoAddress}", + "replicaset": "${bcsClusterManagerMongoReplicaset}" "connecttimeout": ${bcsClusterManagerMongoConnectTimeout}, "database": "${bcsClusterManagerMongoDatabase}", "username": "${bcsClusterManagerMongoUsername}", diff --git a/bcs-services/bcs-cluster-manager/go.mod b/bcs-services/bcs-cluster-manager/go.mod index d87192bac2..4cd1b3b740 100644 --- a/bcs-services/bcs-cluster-manager/go.mod +++ b/bcs-services/bcs-cluster-manager/go.mod @@ -3,6 +3,7 @@ module github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager go 1.20 replace ( + github.com/Tencent/bk-bcs/bcs-common => ../../bcs-common k8s.io/api => k8s.io/api v0.26.1 k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.26.1 k8s.io/apimachinery => k8s.io/apimachinery v0.26.1 diff --git a/bcs-services/bcs-cluster-manager/internal/app/app.go b/bcs-services/bcs-cluster-manager/internal/app/app.go index 5e93fe6490..da25631e14 100644 --- a/bcs-services/bcs-cluster-manager/internal/app/app.go +++ b/bcs-services/bcs-cluster-manager/internal/app/app.go @@ -240,6 +240,7 @@ func (cm *ClusterManager) initModel() error { password := cm.opt.Mongo.Password mongoOptions := &mongo.Options{ Hosts: strings.Split(cm.opt.Mongo.Address, ","), + Replicaset: cm.opt.Mongo.Replicaset, ConnectTimeoutSeconds: int(cm.opt.Mongo.ConnectTimeout), Database: cm.opt.Mongo.Database, Username: cm.opt.Mongo.Username, diff --git a/bcs-services/bcs-cluster-manager/internal/options/options.go b/bcs-services/bcs-cluster-manager/internal/options/options.go index 2e18c16293..838526d871 100644 --- a/bcs-services/bcs-cluster-manager/internal/options/options.go +++ b/bcs-services/bcs-cluster-manager/internal/options/options.go @@ -73,6 +73,7 @@ type TunnelConfig struct { // MongoConfig option for mongo type MongoConfig struct { Address string `json:"address"` + Replicaset string `json:"replicaset"` ConnectTimeout uint `json:"connecttimeout"` Database string `json:"database"` Username string `json:"username"` diff --git a/bcs-services/bcs-cluster-manager/main.go b/bcs-services/bcs-cluster-manager/main.go index 4fb230cdd7..ac5beb4cde 100644 --- a/bcs-services/bcs-cluster-manager/main.go +++ b/bcs-services/bcs-cluster-manager/main.go @@ -66,6 +66,7 @@ func main() { // nolint flag.String("bcslog_backtraceat", "", "when logging hits line file:N, emit a stack trace") // mongo config flag.String("mongo_address", "127.0.0.1:27017", "mongo server address") + flag.String("mongo_replicaset", "", "mongo replica set name") flag.Uint("mongo_connecttimeout", 3, "mongo server connnect timeout") flag.String("mongo_database", "", "database in mongo for cluster manager") flag.String("mongo_username", "", "mongo username for cluster manager") diff --git a/install/conf/bcs-services/bcs-cluster-manager/bcs-cluster-manager.json.template b/install/conf/bcs-services/bcs-cluster-manager/bcs-cluster-manager.json.template index 9bb37b9d08..256f0b9be9 100644 --- a/install/conf/bcs-services/bcs-cluster-manager/bcs-cluster-manager.json.template +++ b/install/conf/bcs-services/bcs-cluster-manager/bcs-cluster-manager.json.template @@ -1,6 +1,7 @@ { "mongo": { "address": "${bcsClusterManagerMongoAddress}", + "replicaset": "${bcsClusterManagerMongoReplicaset}", "connecttimeout": ${bcsClusterManagerMongoConnectTimeout}, "database": "${bcsClusterManagerMongoDatabase}", "username": "${bcsClusterManagerMongoUsername}",