Skip to content

Commit

Permalink
fix: add metricservice as default module, issue #818
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperJim committed Apr 2, 2021
1 parent 855f1da commit 8e20172
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions bcs-services/bcs-gateway-discovery/app/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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 := &register.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down

0 comments on commit 8e20172

Please sign in to comment.