Skip to content

Commit

Permalink
feat: cluster-manager 支持配置mongodb replicaset
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyudeqiu committed Dec 11, 2024
1 parent ec565d5 commit a2ae5d2
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"mongo": {
"address": "${bcsClusterManagerMongoAddress}",
"replicaset": "${bcsClusterManagerMongoReplicaset}"
"connecttimeout": ${bcsClusterManagerMongoConnectTimeout},
"database": "${bcsClusterManagerMongoDatabase}",
"username": "${bcsClusterManagerMongoUsername}",
Expand Down
1 change: 1 addition & 0 deletions bcs-services/bcs-cluster-manager/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions bcs-services/bcs-cluster-manager/internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions bcs-services/bcs-cluster-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"mongo": {
"address": "${bcsClusterManagerMongoAddress}",
"replicaset": "${bcsClusterManagerMongoReplicaset}",
"connecttimeout": ${bcsClusterManagerMongoConnectTimeout},
"database": "${bcsClusterManagerMongoDatabase}",
"username": "${bcsClusterManagerMongoUsername}",
Expand Down

0 comments on commit a2ae5d2

Please sign in to comment.