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
4e90d54c
Commit
4e90d54c
authored
Mar 13, 2019
by
kewei.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除注释代码
parent
57b99a7e
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
616 additions
and
703 deletions
+616
-703
service.js
app/service.js
+31
-40
package-lock.json
package-lock.json
+513
-513
tke.clusterService.js
services/tke.clusterService.js
+2
-6
tke.service.js
services/tke.service.js
+70
-144
No files found.
app/service.js
View file @
4e90d54c
...
...
@@ -13,19 +13,10 @@ router.get('/', async ctx => {
})
router
.
post
(
'
/create
'
,
async
ctx
=>
{
let
{
type
,
serviceName
,
namespace
,
image
,
system_name
,
lable
}
=
ctx
.
request
.
body
let
{
type
,
serviceName
,
namespace
,
image
,
system_name
,
lable
}
=
ctx
.
request
.
body
if
(
!
TYPES
.
includes
(
type
))
{
return
ctx
.
body
=
ctx
.
fail
(
'
不支持的服务类型
'
)
}
// try {
// let svc = await ctx.cluster.service_get(serviceName, namespace)
// if (svc) {
// return ctx.body = ctx.fail('服务已经存在')
// }
// } catch (e) {
// }
let
data
=
{
serviceName
,
namespace
,
...
...
@@ -44,7 +35,7 @@ router.post('/create', async ctx => {
return
data
[
arguments
[
1
]]
})
let
params
=
yaml
.
load
(
template
)
await
ctx
.
cluster
.
service_create
(
params
,
type
)
await
ctx
.
cluster
.
service_create
(
params
,
type
)
ctx
.
body
=
ctx
.
ok
(
'
创建成功
'
)
})
router
.
post
(
'
/details
'
,
async
ctx
=>
{
...
...
package-lock.json
View file @
4e90d54c
This diff is collapsed.
Click to expand it.
services/tke.clusterService.js
View file @
4e90d54c
...
...
@@ -27,14 +27,10 @@ class Cluster extends Client {
return
this
.
post
(
'
DescribeClusterServiceInfo
'
,
{
serviceName
,
namespace
,
clusterId
:
this
.
clusterId
})
}
async
service_create
(
params
,
type
)
{
async
service_create
(
params
,
type
)
{
params
.
clusterId
=
this
.
clusterId
let
str
=
JSON
.
stringify
(
params
)
await
this
.
post
(
'
CreateClusterService
'
,
params
)
// 腾讯云api暂只能通过修改服务来改成Recreate策略
// let modifyParams = JSON.parse(str)
// modifyParams.strategy = 'Recreate'
// return this.post('ModifyClusterService', modifyParams)
let
updateLabels
=
{
clusterId
:
params
.
clusterId
,
serviceName
:
params
.
serviceName
,
...
...
@@ -50,9 +46,9 @@ class Cluster extends Client {
}
service_modifyImage
(
serviceName
,
image
,
namespace
)
{
// 修改示例的第一个容器
return
this
.
post
(
'
ModifyClusterServiceImage
'
,
{
serviceName
,
namespace
,
image
,
clusterId
:
this
.
clusterId
})
}
ingress_get
(
namespace
)
{
return
this
.
post
(
'
DescribeIngress
'
,
{
namespace
,
clusterId
:
this
.
clusterId
})
}
...
...
services/tke.service.js
View file @
4e90d54c
...
...
@@ -3,7 +3,7 @@ const crypto = require('crypto')
const
domainConfig
=
require
(
'
../config
'
)
class
Client
{
constructor
()
{
constructor
()
{
this
.
secretId
=
domainConfig
.
secretId
this
.
secretKey
=
domainConfig
.
secretKey
this
.
region
=
domainConfig
.
region
...
...
@@ -18,7 +18,7 @@ class Client {
this
.
defaultNamespaces
=
[
'
default
'
,
'
kube-system
'
,
'
kube-public
'
]
}
sign
(
params
,
signMethod
)
{
sign
(
params
,
signMethod
)
{
let
str
=
''
let
keys
=
Object
.
keys
(
params
)
keys
.
sort
()
...
...
@@ -43,7 +43,7 @@ class Client {
// Nonce: null,
// SecretId: '',
// Signature: ''
formatRequestData
(
action
,
params
=
{})
{
formatRequestData
(
action
,
params
=
{})
{
params
.
Action
=
action
params
.
Region
=
this
.
region
params
.
Timestamp
=
Math
.
round
(
Date
.
now
()
/
1000
)
...
...
@@ -53,7 +53,7 @@ class Client {
params
.
Signature
=
this
.
sign
(
params
,
params
.
SignatureMethod
)
}
post
(
action
,
params
=
{})
{
post
(
action
,
params
=
{})
{
if
(
params
.
namespace
&&
this
.
defaultNamespaces
.
includes
(
params
.
namespace
))
{
return
Promise
.
reject
(
new
Error
(
'
未授权的namespace
'
))
}
...
...
@@ -81,80 +81,6 @@ class Client {
})
})
}
// namespace_get () {
// return this.post('DescribeClusterNameSpaces', {clusterId: this.clusterId})
// }
//
// namespace_create (name) {
// return this.post('CreateClusterNamespace', {name, description: '', clusterId: this.clusterId})
// }
//
// namespace_delete (name) {
// return this.post('DeleteClusterNamespace', {"names.0": name, clusterId: this.clusterId})
// }
// service_list (namespace) {
// return this.post('DescribeClusterService', {namespace, clusterId: this.clusterId, allnamespace: 0})
// }
//
// service_get (serviceName, namespace) {
// return this.post('DescribeClusterServiceInfo', {serviceName, namespace, clusterId: this.clusterId})
// }
//
// async service_create (params) {
// params.clusterId = this.clusterId
// let str = JSON.stringify(params)
// await this.post('CreateClusterService', params)
// // 腾讯云api暂只能通过修改服务来改成Recreate策略
// let modifyParams = JSON.parse(str)
// modifyParams.strategy = 'Recreate'
// return this.post('ModifyClusterService', modifyParams)
// }
//
// service_delete (serviceName, namespace) {
// return this.post('DeleteClusterService', {serviceName, namespace, clusterId: this.clusterId})
// }
//
// service_modifyImage (serviceName, image, namespace) {
// // 修改示例的第一个容器
// return this.post('ModifyClusterServiceImage', {serviceName, namespace, image, clusterId: this.clusterId})
// }
//
// ingress_get (namespace) {
// return this.post('DescribeIngress', {namespace, clusterId: this.clusterId})
// }
//
// ingress_create (namespace) {
// return this.post('CreateIngress', {ingressName: `qa-${namespace}`, ingressDesc: '', namespace, clusterId: this.clusterId})
// }
//
// ingress_delete (ingressName, namespace) {
// return this.post('DeleteIngress', {ingressName, namespace, clusterId: this.clusterId})
// }
//
// ingress_modify (ingressName, namespace, rules) {
// return this.post('MosifyIngress', {ingressName, namespace, ...rules, clusterId: this.clusterId})
// }
//腾讯仓库列表
// repository_get(namespace1, reponame1) {
// return this.post('SearchUserRepository', {reponame})
// }
}
module
.
exports
=
Client
// exports.create = function (config) {
// return new Client(config)
// }
// let client = new Client({
// secretId: 'AKID4rY7wwNphsUcaFsy1pRtKhQvDj4CA3Ac',
// secretKey: 'YBduRnjgVRGzmagZJbss3Vo58wWCyhgc',
// clusterId: 'cls-acfx4pvj',
// region: 'ap-beijing'
// })
// client.post('DescribeClusterNameSpaces', {clusterId: 'cls-acfx4pvj'}).then(res => {
// console.log(5, res)
// })
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