diff --git a/bcs-services/bcs-gateway-discovery/app/adapter.go b/bcs-services/bcs-gateway-discovery/app/adapter.go index 698b8ce61a..72ed669cfc 100644 --- a/bcs-services/bcs-gateway-discovery/app/adapter.go +++ b/bcs-services/bcs-gateway-discovery/app/adapter.go @@ -26,12 +26,15 @@ import ( "github.com/micro/go-micro/v2/registry" ) +var metricModeule = "metric" + var notStandardRouteModules = map[string]string{ modules.BCSModuleStorage: "storage", modules.BCSModuleMesosdriver: "mesosdriver", modules.BCSModuleNetworkdetection: "networkdetection", modules.BCSModuleKubeagent: "kubeagent", modules.BCSModuleUserManager: "usermanager", + metricModeule: metricModeule, } var defaultModules = []string{} @@ -262,6 +265,8 @@ func (adp *Adapter) initCompatibleMicroModules() error { //kube-apiserver information get by userManager adp.microHandlers[modules.BCSModuleUserManager] = adp.microUserMgr blog.Infof("gateway-discovery init compatible module %s proxy rules", modules.BCSModuleUserManager) + //metricservice information + adp.microHandlers["metric"] = adp.microMetricService return nil } @@ -683,6 +688,37 @@ func (adp *Adapter) microUserMgr(module string, svc *registry.Service) (*registe return regSvc, nil } +//microMetricService convert bcs-cluster-manager service information +// to custom service definition. this is compatible with original bcs-api proxy. +// and further more, api-gateway defines new standard proxy rule for it +func (adp *Adapter) microMetricService(module string, svc *registry.Service) (*register.Service, error) { + labels := make(map[string]string) + labels["module"] = metricModeule + labels["service"] = defaultServiceTag + regSvc := ®ister.Service{ + Name: module, + Protocol: "https", + Host: svc.Name, + Path: fmt.Sprintf("/%s/", metricModeule), + Retries: 1, + Labels: labels, + } + //setting route information + rt := register.Route{ + Name: module, + Protocol: "http", + Paths: []string{fmt.Sprintf("/bcsapi/v4/%s/", metricModeule)}, + PathRewrite: true, + Service: module, + Labels: labels, + } + regSvc.Routes = append(regSvc.Routes, rt) + //setting upstream backend information + bcks := adp.constructUpstreamTarget(svc.Nodes) + regSvc.Backends = append(regSvc.Backends, bcks...) + return regSvc, nil +} + //microNetworkDetection convert bcs-network-detection service information // to custom service definition. this is compatible with original bcs-api proxy. // and further more, api-gateway defines new standard proxy rule for it diff --git a/install/conf/bcs-services/bcs-gateway-discovery/bcs-gateway-discovery.json.template b/install/conf/bcs-services/bcs-gateway-discovery/bcs-gateway-discovery.json.template index 62dd198c99..b26a48c275 100755 --- a/install/conf/bcs-services/bcs-gateway-discovery/bcs-gateway-discovery.json.template +++ b/install/conf/bcs-services/bcs-gateway-discovery/bcs-gateway-discovery.json.template @@ -3,6 +3,7 @@ "log_dir": "${log_dir}", "pid_dir": "${pid_dir}", "v": 3, + "alsologtostderr": true, "ca_file": "${caFile}", "server_cert_file": "${serverCertFile}", "server_key_file": "${serverKeyFile}",