Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cluster-resources支持配置mongodb副本集名称 #3636

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bcs-services/cluster-resources/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ func (crSvc *clusterResourcesService) initModel() error {
// init mongo options
mongoOptions := &mongo.Options{
Hosts: strings.Split(crSvc.conf.Mongo.Address, ","),
Replicaset: crSvc.conf.Mongo.Replicaset,
ConnectTimeoutSeconds: int(crSvc.conf.Mongo.ConnectTimeout),
AuthDatabase: crSvc.conf.Mongo.AuthDatabase,
Database: crSvc.conf.Mongo.Database,
Expand Down
2 changes: 1 addition & 1 deletion bcs-services/cluster-resources/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ replace (

require (
github.com/Masterminds/sprig/v3 v3.2.3
github.com/Tencent/bk-bcs/bcs-common v0.0.0-20241015035856-99f8d8f45458
github.com/Tencent/bk-bcs/bcs-common v0.0.0-20241212023042-2c0651f4eded
github.com/TencentBlueKing/gopkg v1.1.0
github.com/TencentBlueKing/iam-go-sdk v0.1.6
// fork 自 https://github.com/signalfx/splunk-otel-go/tree/main/instrumentation/k8s.io/client-go/splunkclient-go
Expand Down
1 change: 1 addition & 0 deletions bcs-services/cluster-resources/pkg/common/envs/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var (
BKIAMSystemID = envx.Get("BK_IAM_SYSTEM_ID", "")
RedisPassword = envx.Get("REDIS_PASSWORD", "")
MongoAddress = envx.Get("MONGO_ADDRESS", "")
MongoReplicaset = envx.Get("MONGO_REPLICASET", "")
MongoUsername = envx.Get("MONGO_USERNAME", "")
MongoPassword = envx.Get("MONGO_PASSWORD", "")
)
Expand Down
4 changes: 4 additions & 0 deletions bcs-services/cluster-resources/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func LoadConf(filePath string) (*ClusterResourcesConf, error) {
if conf.Mongo.Address == "" {
conf.Mongo.Address = envs.MongoAddress
}
if conf.Mongo.Replicaset == "" {
conf.Mongo.Replicaset = envs.MongoReplicaset
}
if conf.Mongo.Username == "" {
conf.Mongo.Username = envs.MongoUsername
}
Expand Down Expand Up @@ -283,6 +286,7 @@ type RedisConf struct {
// MongoConfig option for mongo
type MongoConfig struct {
Address string `json:"address" yaml:"address"`
Replicaset string `json:"replicaset" yaml:"replicaset"`
ConnectTimeout uint `json:"connectTimeout" yaml:"connectTimeout"`
AuthDatabase string `json:"authDatabase" yaml:"authDatabase"`
Database string `json:"database" yaml:"database"`
Expand Down
Loading