mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-01 03:07:51 +08:00
Merge pull request #784 from GLYASAI/k8sdashboard
proxy traffix to k8s dashboard
This commit is contained in:
commit
71035dba70
@ -181,6 +181,7 @@ func GetPodHandler() PodHandler {
|
||||
|
||||
var defaultEtcdHandler *EtcdHandler
|
||||
|
||||
// GetEtcdHandler returns the default etcd handler.
|
||||
func GetEtcdHandler() *EtcdHandler {
|
||||
return defaultEtcdHandler
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ var nodeProxy proxy.Proxy
|
||||
var builderProxy proxy.Proxy
|
||||
var prometheusProxy proxy.Proxy
|
||||
var monitorProxy proxy.Proxy
|
||||
var kubernetesDashboard proxy.Proxy
|
||||
|
||||
//InitProxy 初始化
|
||||
func InitProxy(conf option.Config) {
|
||||
@ -47,6 +48,9 @@ func InitProxy(conf option.Config) {
|
||||
monitorProxy = proxy.CreateProxy("monitor", "http", []string{"127.0.0.1:3329"})
|
||||
discover.GetEndpointDiscover().AddProject("monitor", monitorProxy)
|
||||
}
|
||||
if kubernetesDashboard == nil {
|
||||
kubernetesDashboard = proxy.CreateProxy("kubernetesdashboard", "http", []string{conf.KuberentesDashboardAPI})
|
||||
}
|
||||
}
|
||||
|
||||
//GetNodeProxy GetNodeProxy
|
||||
@ -68,3 +72,8 @@ func GetPrometheusProxy() proxy.Proxy {
|
||||
func GetMonitorProxy() proxy.Proxy {
|
||||
return monitorProxy
|
||||
}
|
||||
|
||||
// GetKubernetesDashboardProxy returns the kubernetes dashboard proxy.
|
||||
func GetKubernetesDashboardProxy() proxy.Proxy {
|
||||
return kubernetesDashboard
|
||||
}
|
||||
|
@ -180,6 +180,13 @@ func Proxy(next http.Handler) http.Handler {
|
||||
handler.GetMonitorProxy().Proxy(w, r)
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(r.RequestURI, "/kubernetes/dashboard") {
|
||||
logrus.Debugf("proxy traffic to kubernetes dashboard.")
|
||||
proxy := handler.GetKubernetesDashboardProxy()
|
||||
r.URL.Path = strings.Replace(r.URL.Path, "/kubernetes/dashboard", "", 1)
|
||||
proxy.Proxy(w, r)
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
}
|
||||
return http.HandlerFunc(fn)
|
||||
|
@ -151,6 +151,7 @@ func (m *Manager) Run() {
|
||||
//兼容老版docker
|
||||
m.r.Get("/v1/etcd/event-log/instances", m.EventLogInstance)
|
||||
|
||||
m.r.Get("/kubernetes/dashboard", m.KuberntesDashboardAPI)
|
||||
//prometheus单节点代理
|
||||
m.r.Get("/api/v1/query", m.PrometheusAPI)
|
||||
m.r.Get("/api/v1/query_range", m.PrometheusAPI)
|
||||
@ -221,3 +222,8 @@ func (m *Manager) EventLogInstance(w http.ResponseWriter, r *http.Request) {
|
||||
func (m *Manager) PrometheusAPI(w http.ResponseWriter, r *http.Request) {
|
||||
handler.GetPrometheusProxy().Proxy(w, r)
|
||||
}
|
||||
|
||||
// KuberntesDashboardAPI proxy traffix to kubernetes dashboard
|
||||
func (m *Manager) KuberntesDashboardAPI(w http.ResponseWriter, r *http.Request) {
|
||||
handler.GetKubernetesDashboardProxy().Proxy(w, r)
|
||||
}
|
||||
|
@ -27,36 +27,37 @@ import (
|
||||
|
||||
//Config config
|
||||
type Config struct {
|
||||
DBType string
|
||||
APIAddr string
|
||||
APIAddrSSL string
|
||||
DBConnectionInfo string
|
||||
EventLogServers []string
|
||||
NodeAPI []string
|
||||
BuilderAPI []string
|
||||
V1API string
|
||||
MQAPI string
|
||||
EtcdEndpoint []string
|
||||
EtcdCaFile string
|
||||
EtcdCertFile string
|
||||
EtcdKeyFile string
|
||||
APISSL bool
|
||||
APICertFile string
|
||||
APIKeyFile string
|
||||
APICaFile string
|
||||
WebsocketSSL bool
|
||||
WebsocketCertFile string
|
||||
WebsocketKeyFile string
|
||||
WebsocketAddr string
|
||||
Opentsdb string
|
||||
RegionTag string
|
||||
LoggerFile string
|
||||
EnableFeature []string
|
||||
Debug bool
|
||||
MinExtPort int // minimum external port
|
||||
LicensePath string
|
||||
LicSoPath string
|
||||
LogPath string
|
||||
DBType string
|
||||
APIAddr string
|
||||
APIAddrSSL string
|
||||
DBConnectionInfo string
|
||||
EventLogServers []string
|
||||
NodeAPI []string
|
||||
BuilderAPI []string
|
||||
V1API string
|
||||
MQAPI string
|
||||
EtcdEndpoint []string
|
||||
EtcdCaFile string
|
||||
EtcdCertFile string
|
||||
EtcdKeyFile string
|
||||
APISSL bool
|
||||
APICertFile string
|
||||
APIKeyFile string
|
||||
APICaFile string
|
||||
WebsocketSSL bool
|
||||
WebsocketCertFile string
|
||||
WebsocketKeyFile string
|
||||
WebsocketAddr string
|
||||
Opentsdb string
|
||||
RegionTag string
|
||||
LoggerFile string
|
||||
EnableFeature []string
|
||||
Debug bool
|
||||
MinExtPort int // minimum external port
|
||||
LicensePath string
|
||||
LicSoPath string
|
||||
LogPath string
|
||||
KuberentesDashboardAPI string
|
||||
}
|
||||
|
||||
//APIServer apiserver server
|
||||
@ -105,6 +106,7 @@ func (a *APIServer) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.StringVar(&a.LicensePath, "license-path", "/opt/rainbond/etc/license/license.yb", "the license path of the enterprise version.")
|
||||
fs.StringVar(&a.LicSoPath, "license-so-path", "/opt/rainbond/etc/license/license.so", "Dynamic library file path for parsing the license.")
|
||||
fs.StringVar(&a.LogPath, "log-path", "/grdata/logs", "Where Docker log files and event log files are stored.")
|
||||
fs.StringVar(&a.KuberentesDashboardAPI, "k8s-dashboard-api", "kubernetes-dashboard.rbd-system:443", "The service DNS name of Kubernetes dashboard. Default to kubernetes-dashboard.kubernetes-dashboard")
|
||||
}
|
||||
|
||||
//SetLog 设置log
|
||||
|
Loading…
Reference in New Issue
Block a user