Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
凌波微步_大先生
dashboard
提交
c161f128
D
dashboard
项目概览
凌波微步_大先生
/
dashboard
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dashboard
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c161f128
编写于
11月 13, 2015
作者:
P
Piotr Bryk
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #68 from kubernetes/microservice-list-backend
Backend implementation of the service list view
上级
7db6ec2f
48cfc6c4
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
151 addition
and
36 deletion
+151
-36
src/app/backend/apihandler.go
src/app/backend/apihandler.go
+52
-20
src/app/backend/dashboard.go
src/app/backend/dashboard.go
+1
-1
src/app/backend/microservicelist.go
src/app/backend/microservicelist.go
+82
-0
src/app/frontend/index.module.js
src/app/frontend/index.module.js
+2
-2
src/app/frontend/microservicelist/microservicelist.controller.js
.../frontend/microservicelist/microservicelist.controller.js
+2
-2
src/app/frontend/microservicelist/microservicelist.html
src/app/frontend/microservicelist/microservicelist.html
+1
-1
src/app/frontend/microservicelist/microservicelist.module.js
src/app/frontend/microservicelist/microservicelist.module.js
+5
-4
src/app/frontend/microservicelist/microservicelist.state.js
src/app/frontend/microservicelist/microservicelist.state.js
+5
-5
src/app/frontend/zerostate/zerostate.html
src/app/frontend/zerostate/zerostate.html
+1
-1
未找到文件。
src/app/backend/apihandler.go
浏览文件 @
c161f128
...
...
@@ -22,35 +22,67 @@ import (
)
// Creates a new HTTP handler that handles all requests to the API of the backend.
func
CreateApiHandler
(
client
*
client
.
Client
)
http
.
Handler
{
func
CreateHttpApiHandler
(
client
*
client
.
Client
)
http
.
Handler
{
apiHandler
:=
ApiHandler
{
client
}
wsContainer
:=
restful
.
NewContainer
()
// TODO(bryk): This is for tests only. Replace with real implementation once ready.
ws
:=
new
(
restful
.
WebService
)
ws
.
Path
(
"/api/deploy"
)
.
deployWs
:=
new
(
restful
.
WebService
)
deployWs
.
Path
(
"/api/deploy"
)
.
Consumes
(
restful
.
MIME_JSON
)
.
Produces
(
restful
.
MIME_JSON
)
ws
.
Route
(
ws
.
POST
(
""
)
.
To
(
func
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
deployWs
.
Route
(
deployWs
.
POST
(
""
)
.
To
(
apiHandler
.
handleDeploy
)
.
Reads
(
DeployAppConfig
{})
.
Writes
(
DeployAppConfig
{}))
wsContainer
.
Add
(
deployWs
)
microserviceListWs
:=
new
(
restful
.
WebService
)
microserviceListWs
.
Path
(
"/api/microservice"
)
.
Produces
(
restful
.
MIME_JSON
)
microserviceListWs
.
Route
(
microserviceListWs
.
GET
(
""
)
.
To
(
apiHandler
.
handleGetMicroserviceList
)
.
Writes
(
MicroserviceList
{}))
wsContainer
.
Add
(
microserviceListWs
)
return
wsContainer
}
type
ApiHandler
struct
{
client
*
client
.
Client
}
// Handles deploy API call.
func
(
apiHandler
*
ApiHandler
)
handleDeploy
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
cfg
:=
new
(
DeployAppConfig
)
if
err
:=
request
.
ReadEntity
(
cfg
);
err
!=
nil
{
H
andleInternalError
(
response
,
err
)
h
andleInternalError
(
response
,
err
)
return
}
if
err
:=
DeployApp
(
cfg
,
client
);
err
!=
nil
{
H
andleInternalError
(
response
,
err
)
if
err
:=
DeployApp
(
cfg
,
apiHandler
.
client
);
err
!=
nil
{
h
andleInternalError
(
response
,
err
)
return
}
response
.
WriteHeaderAndEntity
(
http
.
StatusCreated
,
cfg
)
})
.
Reads
(
DeployAppConfig
{})
.
Writes
(
DeployAppConfig
{}))
}
wsContainer
.
Add
(
ws
)
// Handles get microservice list API call.
func
(
apiHandler
*
ApiHandler
)
handleGetMicroserviceList
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
return
wsContainer
result
,
err
:=
GetMicroserviceList
(
apiHandler
.
client
)
if
err
!=
nil
{
handleInternalError
(
response
,
err
)
return
}
response
.
WriteHeaderAndEntity
(
http
.
StatusCreated
,
result
)
}
// Handler that writes the given error to the response and sets appropriate HTTP status headers.
func
H
andleInternalError
(
response
*
restful
.
Response
,
err
error
)
{
func
h
andleInternalError
(
response
*
restful
.
Response
,
err
error
)
{
response
.
AddHeader
(
"Content-Type"
,
"text/plain"
)
response
.
WriteErrorString
(
http
.
StatusInternalServerError
,
err
.
Error
()
+
"
\n
"
)
}
src/app/backend/dashboard.go
浏览文件 @
c161f128
...
...
@@ -54,6 +54,6 @@ func main() {
// Run a HTTP server that serves static public files from './public' and handles API calls.
// TODO(bryk): Disable directory listing.
http
.
Handle
(
"/"
,
http
.
FileServer
(
http
.
Dir
(
"./public"
)))
http
.
Handle
(
"/api/"
,
CreateApiHandler
(
apiserverClient
))
http
.
Handle
(
"/api/"
,
Create
Http
ApiHandler
(
apiserverClient
))
glog
.
Fatal
(
http
.
ListenAndServe
(
fmt
.
Sprintf
(
":%d"
,
*
argPort
),
nil
))
}
src/app/backend/microservicelist.go
0 → 100644
浏览文件 @
c161f128
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package
main
import
(
"k8s.io/kubernetes/pkg/api"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
)
// List of microservices in the cluster.
type
MicroserviceList
struct
{
// Unordered list of microservices.
Microservices
[]
Microservice
`json:"microservices"`
}
// Microservice is a Kubernetes replica set plus zero or more Kubernetes services.
type
Microservice
struct
{
// Name of the microservice, derived from the replica set.
Name
string
`json:"name"`
// Replica set that represents the microservice.
ReplicaSet
ReplicaSet
`json:"replicaSet"`
// TODO(bryk): Add service field here.
}
// Replica set model to represent in the user interface.
type
ReplicaSet
struct
{
// Number of pods that are currently running.
PodsRunning
int
`json:"podsRunning"`
// Number of pods that are desired to run in this replica set.
PodsDesired
int
`json:"podsDesired"`
// Container images of the replica set.
ContainerImages
[]
string
`json:"containerImages"`
}
// Returns a list of all microservices in the cluster.
func
GetMicroserviceList
(
client
*
client
.
Client
)
(
*
MicroserviceList
,
error
)
{
list
,
err
:=
client
.
ReplicationControllers
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
if
err
!=
nil
{
return
nil
,
err
}
microserviceList
:=
&
MicroserviceList
{}
for
_
,
element
:=
range
list
.
Items
{
var
containerImages
[]
string
for
_
,
container
:=
range
element
.
Spec
.
Template
.
Spec
.
Containers
{
containerImages
=
append
(
containerImages
,
container
.
Image
)
}
microserviceList
.
Microservices
=
append
(
microserviceList
.
Microservices
,
Microservice
{
Name
:
element
.
ObjectMeta
.
Name
,
ReplicaSet
:
ReplicaSet
{
ContainerImages
:
containerImages
,
PodsRunning
:
element
.
Status
.
Replicas
,
PodsDesired
:
element
.
Spec
.
Replicas
,
},
})
}
return
microserviceList
,
nil
}
src/app/frontend/index.module.js
浏览文件 @
c161f128
...
...
@@ -20,7 +20,7 @@ import chromeModule from './chrome/chrome.module';
import
deployModule
from
'
./deploy/deploy.module
'
;
import
indexConfig
from
'
./index.config
'
;
import
routeConfig
from
'
./index.route
'
;
import
serviceListModule
from
'
./servicelist/
servicelist.module
'
;
import
microserviceListModule
from
'
./microservicelist/micro
servicelist.module
'
;
import
zerostateModule
from
'
./zerostate/zerostate.module
'
;
...
...
@@ -36,7 +36,7 @@ export default angular.module(
'
ui.router
'
,
chromeModule
.
name
,
deployModule
.
name
,
serviceListModule
.
name
,
micro
serviceListModule
.
name
,
zerostateModule
.
name
,
])
.
config
(
indexConfig
)
...
...
src/app/frontend/
servicelist/
servicelist.controller.js
→
src/app/frontend/
microservicelist/micro
servicelist.controller.js
浏览文件 @
c161f128
...
...
@@ -18,9 +18,9 @@
*
* @final
*/
export
default
class
S
erviceListController
{
export
default
class
Micros
erviceListController
{
constructor
()
{
/** @export {!Array<string>} */
this
.
test
Services
=
[
'
srvc1
'
,
'
srvc2
'
];
this
.
test
=
[
'
srvc1
'
,
'
srvc2
'
];
}
}
src/app/frontend/
servicelist/
servicelist.html
→
src/app/frontend/
microservicelist/micro
servicelist.html
浏览文件 @
c161f128
...
...
@@ -16,6 +16,6 @@ limitations under the License.
<div
layout=
"vertical"
layout-fill
>
<header>
Service page. {{ctrl.test
Services
}}
Service page. {{ctrl.test}}
</header>
</div>
src/app/frontend/
servicelist/
servicelist.module.js
→
src/app/frontend/
microservicelist/micro
servicelist.module.js
浏览文件 @
c161f128
...
...
@@ -12,17 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import
stateConfig
from
'
./servicelist.state
'
;
import
stateConfig
from
'
./
micro
servicelist.state
'
;
/**
* Angular module for the service list view.
* Angular module for the
micro
service list view.
*
* The view shows services running in the cluster and allows to manage them.
* The view shows
micro
services running in the cluster and allows to manage them.
*/
export
default
angular
.
module
(
'
kubernetesDashboard.serviceList
'
,
'
kubernetesDashboard.
micro
serviceList
'
,
[
'
ngMaterial
'
,
'
ui.router
'
,
])
.
config
(
stateConfig
);
src/app/frontend/
servicelist/
servicelist.state.js
→
src/app/frontend/
microservicelist/micro
servicelist.state.js
浏览文件 @
c161f128
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import
ServiceListController
from
'
./
servicelist.controller
'
;
import
MicroserviceListController
from
'
./micro
servicelist.controller
'
;
/**
...
...
@@ -22,10 +22,10 @@ import ServiceListController from './servicelist.controller';
* @ngInject
*/
export
default
function
stateConfig
(
$stateProvider
)
{
$stateProvider
.
state
(
'
servicelist
'
,
{
controller
:
S
erviceListController
,
$stateProvider
.
state
(
'
micro
servicelist
'
,
{
controller
:
Micros
erviceListController
,
controllerAs
:
'
ctrl
'
,
url
:
'
/servicelist
'
,
templateUrl
:
'
servicelist/
servicelist.html
'
,
url
:
'
/
micro
servicelist
'
,
templateUrl
:
'
microservicelist/micro
servicelist.html
'
,
});
}
src/app/frontend/zerostate/zerostate.html
浏览文件 @
c161f128
...
...
@@ -16,7 +16,7 @@ limitations under the License.
<div
layout=
"vertical"
layout-fill
>
<header>
Zero state page.
<a
ui-sref=
"
servicelist"
>
Go to
services page
</a>
or
Zero state page.
<a
ui-sref=
"
microservicelist"
>
Go to micro
services page
</a>
or
<a
ui-sref=
"deploy"
>
deploy an app
</a>
.
</header>
</div>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录