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 f7cb6d43ec..9f240ba3a5 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 @@ -194,6 +194,9 @@ "enableInsTypeUsage": ${enableInsTypeUsage}, "enableAllocateCidr": ${enableAllocateCidr} }, + "sharedCluster": { + "annoKeyProjCode": "${bcsSharedClusterAnnoKeyProjCode}" + }, "tagDepart": "${tagDepart}", "prefixVcluster": "${prefixVcluster}", "version": "${bcsClusterManagerVersion}", diff --git a/bcs-services/bcs-cluster-manager/internal/actions/cluster/create_vcluster.go b/bcs-services/bcs-cluster-manager/internal/actions/cluster/create_vcluster.go index f4f91f54b8..864334677d 100644 --- a/bcs-services/bcs-cluster-manager/internal/actions/cluster/create_vcluster.go +++ b/bcs-services/bcs-cluster-manager/internal/actions/cluster/create_vcluster.go @@ -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 } diff --git a/bcs-services/bcs-cluster-manager/internal/app/app.go b/bcs-services/bcs-cluster-manager/internal/app/app.go index c003a84105..95e4569b4b 100644 --- a/bcs-services/bcs-cluster-manager/internal/app/app.go +++ b/bcs-services/bcs-cluster-manager/internal/app/app.go @@ -866,6 +866,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() @@ -1181,6 +1187,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 diff --git a/bcs-services/bcs-cluster-manager/internal/options/options.go b/bcs-services/bcs-cluster-manager/internal/options/options.go index 56f263a807..4be7c94261 100644 --- a/bcs-services/bcs-cluster-manager/internal/options/options.go +++ b/bcs-services/bcs-cluster-manager/internal/options/options.go @@ -292,6 +292,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"` @@ -326,6 +331,7 @@ type ClusterManagerOptions struct { TracingConfig conf.TracingConfig `json:"tracingConfig"` Encrypt encryptv2.Config `json:"encrypt"` Daemon DaemonConfig `json:"daemon"` + SharedCluster SharedClusterConfig `json:"sharedCluster"` ServerConfig ClientConfig } 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 97e2703d4f..09fd875a97 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 @@ -193,6 +193,9 @@ "enableInsTypeUsage": ${enableInsTypeUsage}, "enableAllocateCidr": ${enableAllocateCidr} }, + "sharedCluster": { + "annoKeyProjCode": "${bcsSharedClusterAnnoKeyProjCode}" + }, "tagDepart": "${tagDepart}", "prefixVcluster": "${prefixVcluster}", "version": "${bcsClusterManagerVersion}",