Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tke-eos
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
tke-eos
Commits
1c710fc9
Commit
1c710fc9
authored
Apr 01, 2019
by
kewei.jia
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
# Conflicts: # kubeService/ingress.js
parents
7180107a
0c4bce7c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
31 additions
and
21 deletions
+31
-21
namespace.js
app/namespace.js
+9
-1
service.js
app/service.js
+10
-13
ingress.js
kubeService/ingress.js
+1
-0
java.template.txt
serviceTemplate/java.template.txt
+1
-1
mysql.template.txt
serviceTemplate/mysql.template.txt
+1
-1
node.template.txt
serviceTemplate/node.template.txt
+1
-1
rabbitmq.template.txt
serviceTemplate/rabbitmq.template.txt
+1
-1
redis.template.txt
serviceTemplate/redis.template.txt
+1
-1
ui.template.txt
serviceTemplate/ui.template.txt
+1
-1
zookeeper.template.txt
serviceTemplate/zookeeper.template.txt
+1
-1
tke.clusterService.js
services/tke.clusterService.js
+4
-0
No files found.
app/namespace.js
View file @
1c710fc9
const
Router
=
require
(
'
koa-router
'
)
const
Router
=
require
(
'
koa-router
'
)
const
yaml
=
require
(
'
js-yaml
'
)
const
yaml
=
require
(
'
js-yaml
'
)
const
qs
=
require
(
'
querystring
'
)
const
templates
=
require
(
'
../serviceTemplate
'
)
const
templates
=
require
(
'
../serviceTemplate
'
)
let
newNsKey
=
''
let
newNsKey
=
''
...
@@ -12,9 +13,16 @@ router.get('/', async (ctx) => {
...
@@ -12,9 +13,16 @@ router.get('/', async (ctx) => {
ctx
.
body
=
ctx
.
ok
(
data
)
ctx
.
body
=
ctx
.
ok
(
data
)
})
})
router
.
get
(
'
/info
'
,
async
(
ctx
)
=>
{
const
data
=
await
ctx
.
cluster
.
namespace_get
()
const
ns
=
data
.
namespaces
.
find
(
item
=>
item
.
name
===
qs
.
unescape
(
ctx
.
request
.
query
.
namespace
))
ctx
.
body
=
ctx
.
ok
(
ns
)
})
router
.
post
(
'
/create
'
,
async
(
ctx
)
=>
{
router
.
post
(
'
/create
'
,
async
(
ctx
)
=>
{
await
ctx
.
cluster
.
namespace_create
(
ctx
.
request
.
body
.
name
)
await
ctx
.
cluster
.
namespace_create
(
ctx
.
request
.
body
.
name
)
await
ctx
.
cluster
.
ingress_create
(
ctx
.
request
.
body
.
name
)
//
await ctx.cluster.ingress_create(ctx.request.body.name)
ctx
.
body
=
ctx
.
ok
()
ctx
.
body
=
ctx
.
ok
()
})
})
...
...
app/service.js
View file @
1c710fc9
const
Router
=
require
(
'
koa-router
'
)
const
Router
=
require
(
'
koa-router
'
)
const
yaml
=
require
(
'
js-yaml
'
)
const
yaml
=
require
(
'
js-yaml
'
)
const
logger
=
require
(
'
koa-log4
'
).
getLogger
()
const
templates
=
require
(
'
../serviceTemplate
'
)
const
templates
=
require
(
'
../serviceTemplate
'
)
const
{
ingressCreate
,
ingressDelete
}
=
require
(
'
../kubeService/ingress
'
)
const
{
ingressCreate
,
ingressDelete
}
=
require
(
'
../kubeService/ingress
'
)
const
TYPES
=
[
'
ui
'
,
'
java
'
,
'
node
'
,
'
python
'
,
'
go
'
]
const
router
=
new
Router
()
const
router
=
new
Router
()
module
.
exports
=
router
module
.
exports
=
router
...
@@ -17,32 +15,31 @@ router.get('/', async (ctx) => {
...
@@ -17,32 +15,31 @@ router.get('/', async (ctx) => {
router
.
post
(
'
/create
'
,
async
(
ctx
)
=>
{
router
.
post
(
'
/create
'
,
async
(
ctx
)
=>
{
const
{
const
{
type
,
serviceName
,
namespace
,
image
,
system_name
,
lable
,
type
,
serviceName
,
namespace
,
image
,
system_name
,
domain
,
label
,
}
=
ctx
.
request
.
body
}
=
ctx
.
request
.
body
if
(
!
TYPES
.
includes
(
type
))
{
logger
.
info
(
'
创建服务
'
,
ctx
.
request
.
body
)
ctx
.
body
=
ctx
.
fail
(
'
不支持的服务类型
'
)
return
ctx
.
body
}
const
data
=
{
const
data
=
{
serviceName
,
serviceName
,
namespace
,
namespace
,
image
,
image
,
system_name
,
system_name
,
lable
,
}
}
if
(
!
system_name
)
{
if
(
!
system_name
)
{
// ui abTest的时候不一样
// ui abTest的时候不一样
data
.
system_name
=
serviceName
data
.
system_name
=
serviceName
}
}
const
template
=
templates
[
type
].
replace
(
/{{
([
A-Za-z0-9_
]
+
)
}}/g
,
function
()
{
const
template
=
templates
[
type
].
replace
(
/{{
([
A-Za-z0-9_
]
+
)
}}/g
,
function
()
{
if
(
data
[
arguments
[
1
]]
===
undefined
)
{
if
(
data
[
arguments
[
1
]]
===
undefined
)
{
throw
new
Error
(
'
缺少模板所需变量
'
)
throw
new
Error
(
`缺少模板所需变量:
${
arguments
[
1
]}
`
)
}
}
return
data
[
arguments
[
1
]]
return
data
[
arguments
[
1
]]
})
})
const
params
=
yaml
.
load
(
template
)
const
params
=
yaml
.
load
(
template
)
await
ctx
.
cluster
.
service_create
(
params
,
type
)
await
ctx
.
cluster
.
service_create
(
params
,
label
)
await
ingressCreate
(
namespace
,
serviceName
)
if
(
domain
)
{
await
ingressCreate
({
namespace
,
serviceName
,
domain
})
}
ctx
.
body
=
ctx
.
ok
(
'
创建成功
'
)
ctx
.
body
=
ctx
.
ok
(
'
创建成功
'
)
})
})
router
.
post
(
'
/details
'
,
async
(
ctx
)
=>
{
router
.
post
(
'
/details
'
,
async
(
ctx
)
=>
{
...
...
kubeService/ingress.js
View file @
1c710fc9
...
@@ -4,6 +4,7 @@ const config = require('kubernetes-client').config
...
@@ -4,6 +4,7 @@ const config = require('kubernetes-client').config
// const client = new Client({ config: config.fromKubeconfig(), version: '1.9' })
// const client = new Client({ config: config.fromKubeconfig(), version: '1.9' })
console
.
log
(
path
.
resolve
(
__dirname
,
'
./kubeConfig.yaml
'
))
const
client
=
new
Client
({
const
client
=
new
Client
({
config
:
config
.
fromKubeconfig
(
config
:
config
.
fromKubeconfig
(
path
.
resolve
(
__dirname
,
'
./kubeConfig.yaml
'
),
path
.
resolve
(
__dirname
,
'
./kubeConfig.yaml
'
),
...
...
serviceTemplate/java.template.txt
View file @
1c710fc9
...
@@ -8,7 +8,7 @@ portMappings.0.lbPort: 80
...
@@ -8,7 +8,7 @@ portMappings.0.lbPort: 80
portMappings.0.containerPort: 80
portMappings.0.containerPort: 80
containers.0.containerName: {{system_name}}
containers.0.containerName: {{system_name}}
containers.0.image: {{image}}
containers.0.image:
ccr.ccs.tencentyun.com/
{{image}}
containers.0.envs.0.name: SYSTEM_NAME
containers.0.envs.0.name: SYSTEM_NAME
containers.0.envs.0.value: {{system_name}}
containers.0.envs.0.value: {{system_name}}
containers.0.envs.1.name: NAMESPACE
containers.0.envs.1.name: NAMESPACE
...
...
serviceTemplate/mysql.template.txt
View file @
1c710fc9
...
@@ -8,7 +8,7 @@ portMappings.0.lbPort: 3306
...
@@ -8,7 +8,7 @@ portMappings.0.lbPort: 3306
portMappings.0.containerPort: 3306
portMappings.0.containerPort: 3306
containers.0.containerName: mysql
containers.0.containerName: mysql
containers.0.image: {{image}}
containers.0.image:
ccr.ccs.tencentyun.com/
{{image}}
containers.0.volumeMounts.0.volumeName: mysql-vol
containers.0.volumeMounts.0.volumeName: mysql-vol
containers.0.volumeMounts.0.mountPath: /var/lib/mysql
containers.0.volumeMounts.0.mountPath: /var/lib/mysql
containers.0.volumeMounts.0.mode: rw
containers.0.volumeMounts.0.mode: rw
...
...
serviceTemplate/node.template.txt
View file @
1c710fc9
...
@@ -8,7 +8,7 @@ portMappings.0.lbPort: 80
...
@@ -8,7 +8,7 @@ portMappings.0.lbPort: 80
portMappings.0.containerPort: 80
portMappings.0.containerPort: 80
containers.0.containerName: {{serviceName}}
containers.0.containerName: {{serviceName}}
containers.0.image: {{image}}
containers.0.image:
ccr.ccs.tencentyun.com/
{{image}}
containers.0.envs.0.name: SYSTEM_NAME
containers.0.envs.0.name: SYSTEM_NAME
containers.0.envs.0.value: {{serviceName}}
containers.0.envs.0.value: {{serviceName}}
containers.0.envs.1.name: NAMESPACE
containers.0.envs.1.name: NAMESPACE
...
...
serviceTemplate/rabbitmq.template.txt
View file @
1c710fc9
...
@@ -12,7 +12,7 @@ portMappings.1.lbPort: 15672
...
@@ -12,7 +12,7 @@ portMappings.1.lbPort: 15672
portMappings.1.containerPort: 15672
portMappings.1.containerPort: 15672
containers.0.containerName: rabbitmq
containers.0.containerName: rabbitmq
containers.0.image: {{image}}
containers.0.image:
ccr.ccs.tencentyun.com/
{{image}}
containers.0.volumeMounts.0.volumeName: rabbitmq-vol
containers.0.volumeMounts.0.volumeName: rabbitmq-vol
containers.0.volumeMounts.0.mountPath: /var/lib/rabbitmq
containers.0.volumeMounts.0.mountPath: /var/lib/rabbitmq
containers.0.volumeMounts.0.mode: rw
containers.0.volumeMounts.0.mode: rw
...
...
serviceTemplate/redis.template.txt
View file @
1c710fc9
...
@@ -24,7 +24,7 @@ portMappings.4.lbPort: 6383
...
@@ -24,7 +24,7 @@ portMappings.4.lbPort: 6383
portMappings.4.containerPort: 6383
portMappings.4.containerPort: 6383
containers.0.containerName: redis
containers.0.containerName: redis
containers.0.image: {{image}}
containers.0.image:
ccr.ccs.tencentyun.com/
{{image}}
containers.0.volumeMounts.0.volumeName: redis-vol
containers.0.volumeMounts.0.volumeName: redis-vol
containers.0.volumeMounts.0.mountPath: /var/lib/redis
containers.0.volumeMounts.0.mountPath: /var/lib/redis
containers.0.volumeMounts.0.mode: rw
containers.0.volumeMounts.0.mode: rw
...
...
serviceTemplate/ui.template.txt
View file @
1c710fc9
...
@@ -8,7 +8,7 @@ portMappings.0.lbPort: 80
...
@@ -8,7 +8,7 @@ portMappings.0.lbPort: 80
portMappings.0.containerPort: 80
portMappings.0.containerPort: 80
containers.0.containerName: {{system_name}}
containers.0.containerName: {{system_name}}
containers.0.image: {{image}}
containers.0.image:
ccr.ccs.tencentyun.com/
{{image}}
containers.0.envs.0.name: SYSTEM_NAME
containers.0.envs.0.name: SYSTEM_NAME
containers.0.envs.0.value: {{system_name}}
containers.0.envs.0.value: {{system_name}}
containers.0.envs.1.name: NAMESPACE
containers.0.envs.1.name: NAMESPACE
...
...
serviceTemplate/zookeeper.template.txt
View file @
1c710fc9
...
@@ -12,7 +12,7 @@ portMappings.1.lbPort: 9090
...
@@ -12,7 +12,7 @@ portMappings.1.lbPort: 9090
portMappings.1.containerPort: 9090
portMappings.1.containerPort: 9090
containers.0.containerName: zookeeper
containers.0.containerName: zookeeper
containers.0.image: {{image}}
containers.0.image:
ccr.ccs.tencentyun.com/
{{image}}
containers.0.volumeMounts.0.volumeName: zookeeper-vol
containers.0.volumeMounts.0.volumeName: zookeeper-vol
containers.0.volumeMounts.0.mountPath: /var/lib/zookeeper
containers.0.volumeMounts.0.mountPath: /var/lib/zookeeper
containers.0.volumeMounts.0.mode: rw
containers.0.volumeMounts.0.mode: rw
...
...
services/tke.clusterService.js
View file @
1c710fc9
const
logger
=
require
(
'
koa-log4
'
).
getLogger
()
const
Client
=
require
(
'
./tke.service
'
)
const
Client
=
require
(
'
./tke.service
'
)
const
domainConfig
=
require
(
'
../config
'
)
const
domainConfig
=
require
(
'
../config
'
)
...
@@ -28,6 +30,7 @@ class Cluster extends Client {
...
@@ -28,6 +30,7 @@ class Cluster extends Client {
}
}
async
service_create
(
params
,
type
)
{
async
service_create
(
params
,
type
)
{
logger
.
info
(
'
创建服务详细信息:
'
,
params
,
type
)
params
.
clusterId
=
this
.
clusterId
params
.
clusterId
=
this
.
clusterId
const
str
=
JSON
.
stringify
(
params
)
const
str
=
JSON
.
stringify
(
params
)
await
this
.
post
(
'
CreateClusterService
'
,
params
)
await
this
.
post
(
'
CreateClusterService
'
,
params
)
...
@@ -68,6 +71,7 @@ class Cluster extends Client {
...
@@ -68,6 +71,7 @@ class Cluster extends Client {
}
}
ingress_create
(
namespace
)
{
ingress_create
(
namespace
)
{
logger
.
info
()
return
this
.
post
(
'
CreateIngress
'
,
{
return
this
.
post
(
'
CreateIngress
'
,
{
ingressName
:
`qa-
${
namespace
}
`
,
ingressName
:
`qa-
${
namespace
}
`
,
ingressDesc
:
''
,
ingressDesc
:
''
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment