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-manager支持自定义配置projectcode注解 #3621

Open
wants to merge 2 commits 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
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@
"enableInsTypeUsage": ${enableInsTypeUsage},
"enableAllocateCidr": ${enableAllocateCidr}
},
"sharedCluster": {
"annoKeyProjCode": "${bcsSharedClusterAnnoKeyProjCode}"
},
"tagDepart": "${tagDepart}",
"prefixVcluster": "${prefixVcluster}",
"version": "${bcsClusterManagerVersion}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ func (ca *CreateVirtualClusterAction) validate() error {
}
if ca.req.Ns.Annotations == nil {
ca.req.Ns.Annotations = map[string]string{
utils.ProjectCode: ca.req.ProjectCode,
options.GetGlobalCMOptions().SharedCluster.AnnoKeyProjCode: ca.req.ProjectCode,
utils.NamespaceCreator: ca.req.Creator,
}
} else {
ca.req.Ns.Annotations[utils.ProjectCode] = ca.req.ProjectCode
ca.req.Ns.Annotations[options.GetGlobalCMOptions().SharedCluster.AnnoKeyProjCode] = ca.req.ProjectCode
ca.req.Ns.Annotations[utils.NamespaceCreator] = ca.req.Creator
}

Expand Down
8 changes: 8 additions & 0 deletions bcs-services/bcs-cluster-manager/internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,12 @@ func (cm *ClusterManager) initCommonHandler(router *mux.Router) error {
return nil
}

func (cm *ClusterManager) initSharedClusterConf() {
if cm.opt.SharedCluster.AnnoKeyProjCode == "" {
cm.opt.SharedCluster.AnnoKeyProjCode = utils.ProjectCode
}
}

// initHTTPService init http service
func (cm *ClusterManager) initHTTPService() error {
router := mux.NewRouter()
Expand Down Expand Up @@ -1180,6 +1186,8 @@ func (cm *ClusterManager) Init() error {
blog.Errorf("initCloudTemplateConfig failed: %v", err)
}

// init shared cluster config
cm.initSharedClusterConf()
// init metric, pprof
cm.initExtraModules()
// init system signal handler
Expand Down
6 changes: 6 additions & 0 deletions bcs-services/bcs-cluster-manager/internal/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ type DaemonConfig struct {
EnableAllocateCidr bool `json:"enableAllocateCidr"`
}

// SharedClusterConfig config for shared cluster
type SharedClusterConfig struct {
AnnoKeyProjCode string `json:"annoKeyProjCode"`
}

// ClusterManagerOptions options of cluster manager
type ClusterManagerOptions struct {
Etcd EtcdOption `json:"etcd"`
Expand Down Expand Up @@ -325,6 +330,7 @@ type ClusterManagerOptions struct {
TracingConfig conf.TracingConfig `json:"tracingConfig"`
Encrypt encryptv2.Config `json:"encrypt"`
Daemon DaemonConfig `json:"daemon"`
SharedCluster SharedClusterConfig `json:"sharedCluster"`
ServerConfig
ClientConfig
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@
"enableInsTypeUsage": ${enableInsTypeUsage},
"enableAllocateCidr": ${enableAllocateCidr}
},
"sharedCluster": {
"annoKeyProjCode": "${bcsSharedClusterAnnoKeyProjCode}"
},
"tagDepart": "${tagDepart}",
"prefixVcluster": "${prefixVcluster}",
"version": "${bcsClusterManagerVersion}",
Expand Down
Loading