Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
f1899fe0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f1899fe0
编写于
3月 27, 2019
作者:
J
Jeff
提交者:
zryfish
3月 27, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix health api bug
fix kubebuilder version
上级
8191264b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
56 addition
and
21 deletion
+56
-21
hack/install_kubebuilder.sh
hack/install_kubebuilder.sh
+1
-9
pkg/apis/servicemesh/metrics/v1alpha2/register.go
pkg/apis/servicemesh/metrics/v1alpha2/register.go
+11
-0
pkg/apiserver/servicemesh/metrics/handlers.go
pkg/apiserver/servicemesh/metrics/handlers.go
+5
-0
pkg/controller/destinationrule/destinationrule_controller.go
pkg/controller/destinationrule/destinationrule_controller.go
+21
-3
pkg/controller/strategy/strategy_controller.go
pkg/controller/strategy/strategy_controller.go
+1
-1
pkg/controller/virtualservice/virtualservice_controller.go
pkg/controller/virtualservice/virtualservice_controller.go
+11
-5
vendor/github.com/kiali/kiali/handlers/health.go
vendor/github.com/kiali/kiali/handlers/health.go
+6
-3
未找到文件。
hack/install_kubebuilder.sh
浏览文件 @
f1899fe0
...
...
@@ -45,15 +45,7 @@ esac
command_exists curl
command_exists
tar
if
[
"x
${
KUBEBUILDER_VERSION
}
"
=
"x"
]
;
then
KUBEBUILDER_VERSION
=
$(
curl
-L
-s
https://api.github.com/repos/kubernetes-sigs/kubebuilder/releases/latest?access_token
=
$TOKEN
|
\
grep
tag_name |
sed
"s/ *
\"
tag_name
\"
: *
\"\\
(.*
\\
)
\"
,*/
\\
1/"
)
if
[
-z
"
$KUBEBUILDER_VERSION
"
]
;
then
echo
"
\n
Unable to fetch the latest version tag. This may be due to network access problem"
exit
0
fi
fi
KUBEBUILDER_VERSION
=
v1.0.8
KUBEBUILDER_VERSION
=
${
KUBEBUILDER_VERSION
#
"v"
}
KUBEBUILDER_VERSION_NAME
=
"kubebuilder_
${
KUBEBUILDER_VERSION
}
"
KUBEBUILDER_DIR
=
/usr/local/kubebuilder
...
...
pkg/apis/servicemesh/metrics/v1alpha2/register.go
浏览文件 @
f1899fe0
...
...
@@ -126,6 +126,17 @@ func addWebService(c *restful.Container) error {
Param
(
webservice
.
QueryParameter
(
"namespaces"
,
"names of namespaces"
))
.
Writes
(
errors
.
Error
{}))
.
Produces
(
restful
.
MIME_JSON
)
// Get namespace health
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/health"
)
.
To
(
metrics
.
GetNamespaceHealth
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
tags
)
.
Doc
(
"Get workload health"
)
.
Param
(
webservice
.
PathParameter
(
"namespace"
,
"name of a namespace"
)
.
Required
(
true
))
.
Param
(
webservice
.
PathParameter
(
"type"
,
"the type of health, app/service/workload, default app"
)
.
DefaultValue
(
"app"
))
.
Param
(
webservice
.
QueryParameter
(
"rateInterval"
,
"the rate interval used for fetching error rate"
)
.
DefaultValue
(
"10m"
)
.
Required
(
true
))
.
Param
(
webservice
.
QueryParameter
(
"queryTime"
,
"the time to use for query"
))
.
Writes
(
errors
.
Error
{}))
.
Produces
(
restful
.
MIME_JSON
)
// Get workloads health
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/workloads/{workload}/health"
)
.
To
(
metrics
.
GetWorkloadHealth
)
.
...
...
pkg/apiserver/servicemesh/metrics/handlers.go
浏览文件 @
f1899fe0
...
...
@@ -49,6 +49,11 @@ func GetNamespacesGraph(request *restful.Request, response *restful.Response) {
handlers
.
GraphNamespaces
(
request
,
response
)
}
// Get namespace health
func
GetNamespaceHealth
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
handlers
.
NamespaceHealth
(
request
,
response
)
}
// Get workload health
func
GetWorkloadHealth
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
handlers
.
WorkloadHealth
(
request
,
response
)
...
...
pkg/controller/destinationrule/destinationrule_controller.go
浏览文件 @
f1899fe0
...
...
@@ -74,7 +74,9 @@ func NewDestinationRuleController(deploymentInformer informersv1.DeploymentInfor
destinationRuleClient
istioclientset
.
Interface
)
*
DestinationRuleController
{
broadcaster
:=
record
.
NewBroadcaster
()
broadcaster
.
StartLogging
(
log
.
Info
)
broadcaster
.
StartLogging
(
func
(
format
string
,
args
...
interface
{})
{
log
.
Info
(
fmt
.
Sprintf
(
format
,
args
))
})
broadcaster
.
StartRecordingToSink
(
&
v1core
.
EventSinkImpl
{
Interface
:
client
.
CoreV1
()
.
Events
(
""
)})
recorder
:=
broadcaster
.
NewRecorder
(
scheme
.
Scheme
,
v1
.
EventSource
{
Component
:
"destinationrule-controller"
})
...
...
@@ -95,6 +97,9 @@ func NewDestinationRuleController(deploymentInformer informersv1.DeploymentInfor
deploymentInformer
.
Informer
()
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
v
.
addDeployment
,
DeleteFunc
:
v
.
deleteDeployment
,
UpdateFunc
:
func
(
old
,
cur
interface
{})
{
v
.
addDeployment
(
cur
)
},
})
v
.
serviceLister
=
serviceInformer
.
Lister
()
...
...
@@ -246,7 +251,7 @@ func (v *DestinationRuleController) syncService(key string) error {
}
createDestinationRule
:=
len
(
currentDestinationRule
.
Spec
.
Subsets
)
==
0
createDestinationRule
:=
len
(
currentDestinationRule
.
ResourceVersion
)
==
0
if
!
createDestinationRule
&&
reflect
.
DeepEqual
(
currentDestinationRule
.
Spec
.
Subsets
,
subsets
)
&&
reflect
.
DeepEqual
(
currentDestinationRule
.
Labels
,
service
.
Labels
)
{
...
...
@@ -288,10 +293,23 @@ func (v *DestinationRuleController) syncService(key string) error {
return
nil
}
func
(
v
*
DestinationRuleController
)
isApplicationComponent
(
meta
*
metav1
.
ObjectMeta
)
bool
{
if
len
(
meta
.
Labels
)
>=
len
(
util
.
ApplicationLabels
)
&&
util
.
IsApplicationComponent
(
meta
)
{
return
true
}
return
false
}
// When a destinationrule is added, figure out which service it will be used
// and enqueue it. obj must have *appsv1.Deployment type
func
(
v
*
DestinationRuleController
)
addDeployment
(
obj
interface
{})
{
deploy
:=
obj
.
(
*
appsv1
.
Deployment
)
// not a application component
if
!
v
.
isApplicationComponent
(
&
deploy
.
ObjectMeta
)
{
return
}
services
,
err
:=
v
.
getDeploymentServiceMemberShip
(
deploy
)
if
err
!=
nil
{
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"unable to get deployment %s/%s's service memberships"
,
deploy
.
Namespace
,
deploy
.
Name
))
...
...
@@ -336,7 +354,7 @@ func (v *DestinationRuleController) getDeploymentServiceMemberShip(deployment *a
for
i
:=
range
allServices
{
service
:=
allServices
[
i
]
if
service
.
Spec
.
Selector
==
nil
{
if
service
.
Spec
.
Selector
==
nil
||
!
v
.
isApplicationComponent
(
&
service
.
ObjectMeta
)
{
// services with nil selectors match nothing, not everything.
continue
}
...
...
pkg/controller/strategy/strategy_controller.go
浏览文件 @
f1899fe0
...
...
@@ -115,7 +115,7 @@ func (r *ReconcileStrategy) reconcileStrategy(strategy *servicemeshv1alpha2.Stra
err
:=
r
.
Get
(
context
.
TODO
(),
types
.
NamespacedName
{
Namespace
:
strategy
.
Namespace
,
Name
:
appName
},
service
)
if
err
!=
nil
{
log
.
Error
(
err
,
"couldn't find service
%s/%s,"
,
strategy
.
Namespace
,
appName
)
log
.
Error
(
err
,
"couldn't find service
"
,
"namespace"
,
strategy
.
Namespace
,
"name"
,
appName
)
return
reconcile
.
Result
{},
errors
.
NewBadRequest
(
fmt
.
Sprintf
(
"service %s not found"
,
appName
))
}
...
...
pkg/controller/virtualservice/virtualservice_controller.go
浏览文件 @
f1899fe0
...
...
@@ -77,7 +77,9 @@ func NewVirtualServiceController(serviceInformer coreinformers.ServiceInformer,
virtualServiceClient
istioclient
.
Interface
)
*
VirtualServiceController
{
broadcaster
:=
record
.
NewBroadcaster
()
broadcaster
.
StartLogging
(
log
.
Info
)
broadcaster
.
StartLogging
(
func
(
format
string
,
args
...
interface
{})
{
log
.
Info
(
fmt
.
Sprintf
(
format
,
args
))
})
broadcaster
.
StartRecordingToSink
(
&
v1core
.
EventSinkImpl
{
Interface
:
client
.
CoreV1
()
.
Events
(
""
)})
recorder
:=
broadcaster
.
NewRecorder
(
scheme
.
Scheme
,
v1
.
EventSource
{
Component
:
"virtualservice-controller"
})
...
...
@@ -115,6 +117,9 @@ func NewVirtualServiceController(serviceInformer coreinformers.ServiceInformer,
destinationRuleInformer
.
Informer
()
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
v
.
addDestinationRule
,
UpdateFunc
:
func
(
old
,
cur
interface
{})
{
v
.
addDestinationRule
(
cur
)
},
})
v
.
virtualServiceLister
=
virtualServiceInformer
.
Lister
()
...
...
@@ -128,7 +133,7 @@ func NewVirtualServiceController(serviceInformer coreinformers.ServiceInformer,
}
func
(
v
*
VirtualServiceController
)
Start
(
stopCh
<-
chan
struct
{})
error
{
v
.
Run
(
1
,
stopCh
)
v
.
Run
(
5
,
stopCh
)
return
nil
}
...
...
@@ -194,8 +199,9 @@ func (v *VirtualServiceController) syncService(key string) error {
service
,
err
:=
v
.
serviceLister
.
Services
(
namespace
)
.
Get
(
name
)
if
err
!=
nil
{
// Delete the corresponding virtualservice, as the service has been deleted.
err
=
v
.
virtualServiceClient
.
NetworkingV1alpha3
()
.
VirtualServices
(
namespace
)
.
Delete
(
service
.
N
ame
,
nil
)
err
=
v
.
virtualServiceClient
.
NetworkingV1alpha3
()
.
VirtualServices
(
namespace
)
.
Delete
(
n
ame
,
nil
)
if
err
!=
nil
&&
!
errors
.
IsNotFound
(
err
)
{
log
.
Error
(
err
,
"delete orphan virtualservice failed"
,
"namespace"
,
service
.
Namespace
,
"name"
,
service
.
Name
)
return
err
}
return
nil
...
...
@@ -230,7 +236,7 @@ func (v *VirtualServiceController) syncService(key string) error {
if
len
(
subsets
)
==
0
{
// destination rule with no subsets, not possibly
err
=
fmt
.
Errorf
(
"find destinationrule with no subsets for service %s"
,
name
)
log
.
Error
(
err
,
"Find destinationrule with no subsets for service"
,
"
service"
,
service
.
String
()
)
log
.
Error
(
err
,
"Find destinationrule with no subsets for service"
,
"
namespace"
,
service
.
Namespace
,
"name"
,
name
)
return
err
}
else
{
vs
=
&
v1alpha3
.
VirtualService
{
...
...
@@ -293,7 +299,7 @@ func (v *VirtualServiceController) addDestinationRule(obj interface{}) {
service
,
err
:=
v
.
serviceLister
.
Services
(
dr
.
Namespace
)
.
Get
(
dr
.
Name
)
if
err
!=
nil
{
if
errors
.
IsNotFound
(
err
)
{
log
.
V
(
0
)
.
Info
(
"service not created yet"
,
"
key
"
,
dr
.
Name
)
log
.
V
(
0
)
.
Info
(
"service not created yet"
,
"
namespace"
,
dr
.
Namespace
,
"service
"
,
dr
.
Name
)
return
}
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"unable to get service with name %s/%s"
,
dr
.
Namespace
,
dr
.
Name
))
...
...
vendor/github.com/kiali/kiali/handlers/health.go
浏览文件 @
f1899fe0
...
...
@@ -154,10 +154,13 @@ type baseHealthParams struct {
func
(
p
*
baseHealthParams
)
baseExtract
(
request
*
restful
.
Request
)
{
p
.
RateInterval
=
defaultHealthRateInterval
p
.
QueryTime
=
util
.
Clock
.
Now
()
p
.
QueryTime
=
time
.
Now
()
p
.
RateInterval
=
request
.
QueryParameter
(
"rateInterval"
)
p
.
Namespace
=
request
.
PathParameters
()[
"namespace"
]
if
len
(
request
.
QueryParameter
(
"rateInterval"
))
>
0
{
p
.
RateInterval
=
request
.
QueryParameter
(
"rateInterval"
)
}
p
.
Namespace
=
request
.
PathParameter
(
"namespace"
)
}
// namespaceHealthParams holds the path and query parameters for NamespaceHealth
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录