Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
8ad17a46
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
未验证
提交
8ad17a46
编写于
4月 17, 2020
作者:
Z
Zhengyi Lai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add network configuration to apiserver/config
上级
828f7726
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
84 addition
and
24 deletion
+84
-24
cmd/ks-apiserver/app/options/options.go
cmd/ks-apiserver/app/options/options.go
+3
-0
cmd/ks-apiserver/app/options/validation.go
cmd/ks-apiserver/app/options/validation.go
+1
-0
pkg/apiserver/apiserver.go
pkg/apiserver/apiserver.go
+1
-1
pkg/apiserver/config/config.go
pkg/apiserver/config/config.go
+7
-0
pkg/apiserver/config/config_test.go
pkg/apiserver/config/config_test.go
+4
-0
pkg/kapis/network/v1alpha2/handler.go
pkg/kapis/network/v1alpha2/handler.go
+27
-17
pkg/kapis/network/v1alpha2/register.go
pkg/kapis/network/v1alpha2/register.go
+8
-5
pkg/simple/client/network/options.go
pkg/simple/client/network/options.go
+32
-0
tools/cmd/doc-gen/main.go
tools/cmd/doc-gen/main.go
+1
-1
未找到文件。
cmd/ks-apiserver/app/options/options.go
浏览文件 @
8ad17a46
...
...
@@ -17,6 +17,7 @@ import (
"kubesphere.io/kubesphere/pkg/simple/client/ldap"
esclient
"kubesphere.io/kubesphere/pkg/simple/client/logging/elasticsearch"
"kubesphere.io/kubesphere/pkg/simple/client/monitoring/prometheus"
"kubesphere.io/kubesphere/pkg/simple/client/network"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
"kubesphere.io/kubesphere/pkg/simple/client/s3"
fakes3
"kubesphere.io/kubesphere/pkg/simple/client/s3/fake"
...
...
@@ -43,6 +44,7 @@ func NewServerRunOptions() *ServerRunOptions {
DevopsOptions
:
jenkins
.
NewDevopsOptions
(),
SonarQubeOptions
:
sonarqube
.
NewSonarQubeOptions
(),
ServiceMeshOptions
:
servicemesh
.
NewServiceMeshOptions
(),
NetworkOptions
:
network
.
NewNetworkOptions
(),
MonitoringOptions
:
prometheus
.
NewPrometheusOptions
(),
S3Options
:
s3
.
NewS3Options
(),
OpenPitrixOptions
:
openpitrix
.
NewOptions
(),
...
...
@@ -68,6 +70,7 @@ func (s *ServerRunOptions) Flags() (fss cliflag.NamedFlagSets) {
s
.
RedisOptions
.
AddFlags
(
fss
.
FlagSet
(
"redis"
),
s
.
RedisOptions
)
s
.
S3Options
.
AddFlags
(
fss
.
FlagSet
(
"s3"
),
s
.
S3Options
)
s
.
OpenPitrixOptions
.
AddFlags
(
fss
.
FlagSet
(
"openpitrix"
),
s
.
OpenPitrixOptions
)
s
.
NetworkOptions
.
AddFlags
(
fss
.
FlagSet
(
"network"
),
s
.
NetworkOptions
)
s
.
ServiceMeshOptions
.
AddFlags
(
fss
.
FlagSet
(
"servicemesh"
),
s
.
ServiceMeshOptions
)
s
.
MonitoringOptions
.
AddFlags
(
fss
.
FlagSet
(
"monitoring"
),
s
.
MonitoringOptions
)
s
.
LoggingOptions
.
AddFlags
(
fss
.
FlagSet
(
"logging"
),
s
.
LoggingOptions
)
...
...
cmd/ks-apiserver/app/options/validation.go
浏览文件 @
8ad17a46
...
...
@@ -13,6 +13,7 @@ func (s *ServerRunOptions) Validate() []error {
errors
=
append
(
errors
,
s
.
SonarQubeOptions
.
Validate
()
...
)
errors
=
append
(
errors
,
s
.
S3Options
.
Validate
()
...
)
errors
=
append
(
errors
,
s
.
OpenPitrixOptions
.
Validate
()
...
)
errors
=
append
(
errors
,
s
.
NetworkOptions
.
Validate
()
...
)
errors
=
append
(
errors
,
s
.
LoggingOptions
.
Validate
()
...
)
return
errors
...
...
pkg/apiserver/apiserver.go
浏览文件 @
8ad17a46
...
...
@@ -140,7 +140,7 @@ func (s *APIServer) installKubeSphereAPIs() {
urlruntime
.
Must
(
loggingv1alpha2
.
AddToContainer
(
s
.
container
,
s
.
KubernetesClient
,
s
.
LoggingClient
))
urlruntime
.
Must
(
monitoringv1alpha3
.
AddToContainer
(
s
.
container
,
s
.
KubernetesClient
.
Kubernetes
(),
s
.
MonitoringClient
))
urlruntime
.
Must
(
openpitrixv1
.
AddToContainer
(
s
.
container
,
s
.
InformerFactory
,
s
.
OpenpitrixClient
))
urlruntime
.
Must
(
networkv1alpha2
.
AddToContainer
(
s
.
container
))
urlruntime
.
Must
(
networkv1alpha2
.
AddToContainer
(
s
.
container
,
s
.
Config
.
NetworkOptions
.
WeaveScopeHost
))
urlruntime
.
Must
(
operationsv1alpha2
.
AddToContainer
(
s
.
container
,
s
.
KubernetesClient
.
Kubernetes
()))
urlruntime
.
Must
(
resourcesv1alpha2
.
AddToContainer
(
s
.
container
,
s
.
KubernetesClient
.
Kubernetes
(),
s
.
InformerFactory
))
urlruntime
.
Must
(
tenantv1alpha2
.
AddToContainer
(
s
.
container
,
s
.
KubernetesClient
,
s
.
InformerFactory
))
...
...
pkg/apiserver/config/config.go
浏览文件 @
8ad17a46
...
...
@@ -11,6 +11,7 @@ import (
"kubesphere.io/kubesphere/pkg/simple/client/ldap"
"kubesphere.io/kubesphere/pkg/simple/client/logging/elasticsearch"
"kubesphere.io/kubesphere/pkg/simple/client/monitoring/prometheus"
"kubesphere.io/kubesphere/pkg/simple/client/network"
"kubesphere.io/kubesphere/pkg/simple/client/notification"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
"kubesphere.io/kubesphere/pkg/simple/client/s3"
...
...
@@ -61,6 +62,7 @@ type Config struct {
SonarQubeOptions
*
sonarqube
.
Options
`json:"sonarqube,omitempty" yaml:"sonarQube,omitempty" mapstructure:"sonarqube"`
KubernetesOptions
*
k8s
.
KubernetesOptions
`json:"kubernetes,omitempty" yaml:"kubernetes,omitempty" mapstructure:"kubernetes"`
ServiceMeshOptions
*
servicemesh
.
Options
`json:"servicemesh,omitempty" yaml:"servicemesh,omitempty" mapstructure:"servicemesh"`
NetworkOptions
*
network
.
Options
`json:"network,omitempty" yaml:"network,omitempty" mapstructure:"network"`
LdapOptions
*
ldap
.
Options
`json:"ldap,omitempty" yaml:"ldap,omitempty" mapstructure:"ldap"`
RedisOptions
*
cache
.
Options
`json:"redis,omitempty" yaml:"redis,omitempty" mapstructure:"redis"`
S3Options
*
s3
.
Options
`json:"s3,omitempty" yaml:"s3,omitempty" mapstructure:"s3"`
...
...
@@ -81,6 +83,7 @@ func New() *Config {
SonarQubeOptions
:
sonarqube
.
NewSonarQubeOptions
(),
KubernetesOptions
:
k8s
.
NewKubernetesOptions
(),
ServiceMeshOptions
:
servicemesh
.
NewServiceMeshOptions
(),
NetworkOptions
:
network
.
NewNetworkOptions
(),
LdapOptions
:
ldap
.
NewOptions
(),
RedisOptions
:
cache
.
NewRedisOptions
(),
S3Options
:
s3
.
NewS3Options
(),
...
...
@@ -175,6 +178,10 @@ func (conf *Config) stripEmptyOptions() {
conf
.
OpenPitrixOptions
=
nil
}
if
conf
.
NetworkOptions
!=
nil
&&
conf
.
NetworkOptions
.
WeaveScopeHost
==
""
{
conf
.
NetworkOptions
=
nil
}
if
conf
.
ServiceMeshOptions
!=
nil
&&
conf
.
ServiceMeshOptions
.
IstioPilotHost
==
""
&&
conf
.
ServiceMeshOptions
.
ServicemeshPrometheusHost
==
""
&&
conf
.
ServiceMeshOptions
.
JaegerQueryHost
==
""
{
...
...
pkg/apiserver/config/config_test.go
浏览文件 @
8ad17a46
...
...
@@ -14,6 +14,7 @@ import (
"kubesphere.io/kubesphere/pkg/simple/client/ldap"
"kubesphere.io/kubesphere/pkg/simple/client/logging/elasticsearch"
"kubesphere.io/kubesphere/pkg/simple/client/monitoring/prometheus"
"kubesphere.io/kubesphere/pkg/simple/client/network"
"kubesphere.io/kubesphere/pkg/simple/client/notification"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
"kubesphere.io/kubesphere/pkg/simple/client/s3"
...
...
@@ -79,6 +80,9 @@ func newTestConfig() (*Config, error) {
CategoryManagerEndpoint
:
"openpitrix-hyperpitrix.openpitrix-system.svc:9113"
,
AttachmentManagerEndpoint
:
"openpitrix-hyperpitrix.openpitrix-system.svc:9122"
,
},
NetworkOptions
:
&
network
.
Options
{
WeaveScopeHost
:
"weave-scope-app.weave.svc"
,
},
MonitoringOptions
:
&
prometheus
.
Options
{
Endpoint
:
"http://prometheus.kubesphere-monitoring-system.svc"
,
SecondaryEndpoint
:
"http://prometheus.kubesphere-monitoring-system.svc"
,
...
...
pkg/kapis/network/v1alpha2/handler.go
浏览文件 @
8ad17a46
...
...
@@ -3,35 +3,45 @@ package v1alpha2
import
(
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
restful
"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api"
)
const
ScopeQueryUrl
=
"http://weave-scope-app.weave.svc/api/topology/services"
const
ScopeQueryUrl
=
"http://%s/api/topology/services"
type
handler
struct
{
weaveScopeHost
string
}
func
(
h
*
handler
)
getScopeUrl
()
string
{
return
fmt
.
Sprintf
(
ScopeQueryUrl
,
h
.
weaveScopeHost
)
}
func
getNamespaceTopology
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
func
(
h
*
handler
)
getNamespaceTopology
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
var
query
=
url
.
Values
{
"namespace"
:
[]
string
{
request
.
PathParameter
(
"namespace"
)},
"timestamp"
:
request
.
QueryParameters
(
"timestamp"
),
}
var
u
=
fmt
.
Sprintf
(
"%s?%s"
,
ScopeQueryUrl
,
query
.
Encode
())
var
u
=
fmt
.
Sprintf
(
"%s?%s"
,
h
.
getScopeUrl
()
,
query
.
Encode
())
resp
,
err
:=
http
.
Get
(
u
)
if
err
!=
nil
{
log
.
Print
f
(
"query scope faile with err %v"
,
err
)
_
=
response
.
WriteError
(
http
.
StatusInternalServerError
,
err
)
klog
.
Error
f
(
"query scope faile with err %v"
,
err
)
api
.
HandleInternalError
(
response
,
nil
,
err
)
return
}
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
defer
resp
.
Body
.
Close
()
if
err
!=
nil
{
log
.
Print
f
(
"read response error : %v"
,
err
)
_
=
response
.
WriteError
(
http
.
StatusInternalServerError
,
err
)
klog
.
Error
f
(
"read response error : %v"
,
err
)
api
.
HandleInternalError
(
response
,
nil
,
err
)
return
}
...
...
@@ -40,30 +50,30 @@ func getNamespaceTopology(request *restful.Request, response *restful.Response)
_
,
err
=
response
.
Write
(
body
)
if
err
!=
nil
{
log
.
Print
f
(
"write response failed %v"
,
err
)
klog
.
Error
f
(
"write response failed %v"
,
err
)
}
}
func
getNamespaceNodeTopology
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
func
(
h
*
handler
)
getNamespaceNodeTopology
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
var
query
=
url
.
Values
{
"namespace"
:
[]
string
{
request
.
PathParameter
(
"namespace"
)},
"timestamp"
:
request
.
QueryParameters
(
"timestamp"
),
}
var
u
=
fmt
.
Sprintf
(
"%s/%s?%s"
,
ScopeQueryUrl
,
request
.
PathParameter
(
"node_id"
),
query
.
Encode
())
var
u
=
fmt
.
Sprintf
(
"%s/%s?%s"
,
h
.
getScopeUrl
()
,
request
.
PathParameter
(
"node_id"
),
query
.
Encode
())
resp
,
err
:=
http
.
Get
(
u
)
if
err
!=
nil
{
log
.
Print
f
(
"query scope faile with err %v"
,
err
)
_
=
response
.
WriteError
(
http
.
StatusInternalServerError
,
err
)
klog
.
Error
f
(
"query scope faile with err %v"
,
err
)
api
.
HandleInternalError
(
response
,
nil
,
err
)
return
}
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
defer
resp
.
Body
.
Close
()
if
err
!=
nil
{
log
.
Print
f
(
"read response error : %v"
,
err
)
_
=
response
.
WriteError
(
http
.
StatusInternalServerError
,
err
)
klog
.
Error
f
(
"read response error : %v"
,
err
)
api
.
HandleInternalError
(
response
,
nil
,
err
)
return
}
...
...
@@ -72,6 +82,6 @@ func getNamespaceNodeTopology(request *restful.Request, response *restful.Respon
_
,
err
=
response
.
Write
(
body
)
if
err
!=
nil
{
log
.
Print
f
(
"write response failed %v"
,
err
)
klog
.
Error
f
(
"write response failed %v"
,
err
)
}
}
pkg/kapis/network/v1alpha2/register.go
浏览文件 @
8ad17a46
...
...
@@ -30,25 +30,28 @@ const GroupName = "network.kubesphere.io"
var
GroupVersion
=
schema
.
GroupVersion
{
Group
:
GroupName
,
Version
:
"v1alpha2"
}
func
AddToContainer
(
c
*
restful
.
Container
)
error
{
func
AddToContainer
(
c
*
restful
.
Container
,
weaveScopeHost
string
)
error
{
webservice
:=
runtime
.
NewWebService
(
GroupVersion
)
h
:=
handler
{
weaveScopeHost
:
weaveScopeHost
}
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/topology"
)
.
To
(
getNamespaceTopology
)
.
To
(
h
.
getNamespaceTopology
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
NetworkTopologyTag
})
.
Doc
(
"Get the topology with specifying a namespace"
)
.
Param
(
webservice
.
PathParameter
(
"namespace"
,
"name of the namespace"
)
.
Required
(
true
))
.
Returns
(
http
.
StatusOK
,
"ok"
,
TopologyResponse
{})
.
Writes
(
TopologyResponse
{}))
.
Produces
(
restful
.
MIME_JSON
)
Writes
(
TopologyResponse
{}))
.
Produces
(
restful
.
MIME_JSON
)
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/topology/{node_id}"
)
.
To
(
getNamespaceNodeTopology
)
.
To
(
h
.
getNamespaceNodeTopology
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
NetworkTopologyTag
})
.
Doc
(
"Get the topology with specifying a node id in the whole topology and specifying a namespace"
)
.
Param
(
webservice
.
PathParameter
(
"namespace"
,
"name of the namespace"
)
.
Required
(
true
))
.
Param
(
webservice
.
PathParameter
(
"node_id"
,
"id of the node in the whole topology"
)
.
Required
(
true
))
.
Returns
(
http
.
StatusOK
,
"ok"
,
NodeResponse
{})
.
Writes
(
NodeResponse
{}))
.
Produces
(
restful
.
MIME_JSON
)
Writes
(
NodeResponse
{}))
.
Produces
(
restful
.
MIME_JSON
)
c
.
Add
(
webservice
)
...
...
pkg/simple/client/network/options.go
0 → 100644
浏览文件 @
8ad17a46
package
network
import
"github.com/spf13/pflag"
type
Options
struct
{
// weave scope service host
WeaveScopeHost
string
`json:"weaveScopeHost,omitempty" yaml:"weaveScopeHost"`
}
// NewNetworkOptions returns a `zero` instance
func
NewNetworkOptions
()
*
Options
{
return
&
Options
{
WeaveScopeHost
:
"weave-scope-app.weave.svc"
,
}
}
func
(
s
*
Options
)
Validate
()
[]
error
{
var
errors
[]
error
return
errors
}
func
(
s
*
Options
)
ApplyTo
(
options
*
Options
)
{
if
s
.
WeaveScopeHost
!=
""
{
options
.
WeaveScopeHost
=
s
.
WeaveScopeHost
}
}
func
(
s
*
Options
)
AddFlags
(
fs
*
pflag
.
FlagSet
,
c
*
Options
)
{
fs
.
StringVar
(
&
s
.
WeaveScopeHost
,
"weave-scope-host"
,
c
.
WeaveScopeHost
,
""
+
"weave scope service host"
)
}
tools/cmd/doc-gen/main.go
浏览文件 @
8ad17a46
...
...
@@ -123,7 +123,7 @@ func generateSwaggerJson() []byte {
urlruntime
.
Must
(
tenantv1alpha2
.
AddToContainer
(
container
,
clientsets
,
informerFactory
))
urlruntime
.
Must
(
terminalv1alpha2
.
AddToContainer
(
container
,
clientsets
.
Kubernetes
(),
nil
))
urlruntime
.
Must
(
metricsv1alpha2
.
AddToContainer
(
container
))
urlruntime
.
Must
(
networkv1alpha2
.
AddToContainer
(
container
))
urlruntime
.
Must
(
networkv1alpha2
.
AddToContainer
(
container
,
""
))
config
:=
restfulspec
.
Config
{
WebServices
:
container
.
RegisteredWebServices
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录