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
0892b50a
Commit
0892b50a
authored
Jul 31, 2019
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新部署
parent
014642b6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
37 deletions
+43
-37
service.js
app/service.js
+13
-11
index.js
config/index.js
+2
-2
service.js
kubeService/service.js
+22
-24
resourceLimit.js
serviceTemplate/resourceLimit.js
+5
-0
java.yaml
yamls/java.yaml
+1
-0
No files found.
app/service.js
View file @
0892b50a
...
...
@@ -15,7 +15,7 @@ const {
serviceRestart
,
serviceDelete
,
imageUpdate
,
// getReplicaSet
,
deployUpdate
,
replicaSetDelete
,
pvcDelete
,
}
=
require
(
'
../kubeService/service
'
)
...
...
@@ -72,7 +72,6 @@ router.post('/details', async (ctx) => {
router
.
post
(
'
/delete
'
,
async
(
ctx
)
=>
{
const
{
namespace
,
serviceName
,
podName
}
=
ctx
.
request
.
body
const
key
=
`
${
namespace
}
:
${
podName
}
#
${
serviceName
}
`
console
.
log
(
key
)
const
res
=
await
redis
.
get
(
key
)
await
redis
.
del
(
key
)
if
(
res
)
{
...
...
@@ -101,15 +100,6 @@ router.post('/modifyImage', async (ctx) => {
if
(
list
.
includes
(
ctx
.
request
.
body
.
serviceName
))
{
await
imageUpdate
(
ctx
.
request
.
body
)
// const data = ctx.request.body
// if (!data.label) {
// data.label = data.type
// }
// const resources = makeResouce(data.serviceName, data.label)
// data.resources = resources
// logger.info('更新服务', data)
// await serviceUpdate(data)
}
else
{
await
createService
(
ctx
)
}
...
...
@@ -117,6 +107,18 @@ router.post('/modifyImage', async (ctx) => {
ctx
.
body
=
ctx
.
ok
(
'
更新成功
'
)
})
router
.
post
(
'
/modifyDeploy
'
,
async
(
ctx
)
=>
{
const
data
=
ctx
.
request
.
body
if
(
!
data
.
label
)
{
data
.
label
=
data
.
type
}
const
resources
=
makeResouce
(
data
.
serviceName
,
data
.
label
)
data
.
resources
=
resources
await
deployUpdate
(
data
)
ctx
.
body
=
ctx
.
ok
(
'
更新成功
'
)
})
router
.
post
(
'
/redeploy
'
,
async
(
ctx
)
=>
{
const
key
=
`
${
ctx
.
request
.
body
.
namespace
}
:
${
ctx
.
request
.
body
.
podName
}
#
${
ctx
.
request
.
body
.
serviceName
}
`
const
res
=
await
redis
.
get
(
key
)
...
...
config/index.js
View file @
0892b50a
...
...
@@ -11,7 +11,7 @@ module.exports = {
path
:
'
/v2/index.php
'
,
domain
:
'
.lkbang.com
'
,
noHealthCheckApp
:
[
'
acs-batch
'
,
'
acs-quartz
'
,
'
acs-service
'
,
'
pcm
'
,
'
talos
'
,
'
app-server
'
]
'
acs-batch
'
,
'
acs-quartz
'
,
'
acs-service
'
,
'
pcm
'
,
'
vcc-talos
'
,
'
app-server
'
,
]
,
}
kubeService/service.js
View file @
0892b50a
...
...
@@ -35,37 +35,35 @@ const makeManifest = (data) => {
return
_
.
get
(
data
,
arguments
[
1
])
})
const
yaml
Array
=
yamlManifest
.
split
(
'
---
'
)
return
yaml
Array
const
manifest
Array
=
yamlManifest
.
split
(
'
---
'
)
return
manifest
Array
}
const
serviceCreate
=
async
(
data
)
=>
{
const
{
namespace
,
serviceName
}
=
data
const
yamlArray
=
makeManifest
(
data
)
for
(
const
item
of
yamlArray
)
{
const
jsonObj
=
yaml
.
load
(
item
);
const
manifestArray
=
makeManifest
(
data
)
for
(
const
item
of
manifestArray
)
{
let
manifest
=
yaml
.
load
(
item
);
let
pvc
let
pvcName
switch
(
jsonObj
.
kind
)
{
switch
(
manifest
.
kind
)
{
case
'
Service
'
:
if
(
data
.
wechat
===
'
"1"
'
)
{
jsonObj
.
spec
.
type
=
'
NodePort
'
manifest
.
spec
.
type
=
'
NodePort
'
}
logger
.
info
(
'
创建svc
'
,
JSON
.
stringify
(
jsonObj
))
await
client
.
api
.
v1
.
namespaces
(
namespace
).
services
.
post
({
body
:
jsonObj
})
logger
.
info
(
'
创建svc
'
,
JSON
.
stringify
(
manifest
))
await
client
.
api
.
v1
.
namespaces
(
namespace
).
services
.
post
({
body
:
manifest
})
break
;
case
'
Deployment
'
:
let
obj
=
jsonObj
if
(
APP_CONFIG
.
noHealthCheckApp
.
includes
(
serviceName
))
{
obj
=
_
.
omit
(
jsonObj
,
[
'
spec.template.spec.containers[0].readinessProbe
'
])
manifest
=
_
.
omit
(
manifest
,
[
'
spec.template.spec.containers[0].readinessProbe
'
])
}
logger
.
info
(
'
创建deploy
'
,
serviceName
,
JSON
.
stringify
(
obj
))
logger
.
info
(
'
创建deploy
'
,
serviceName
,
JSON
.
stringify
(
manifest
))
await
client
.
apis
.
apps
.
v1beta1
.
namespaces
(
namespace
).
deployments
.
post
({
body
:
obj
})
await
client
.
apis
.
apps
.
v1beta1
.
namespaces
(
namespace
).
deployments
.
post
({
body
:
manifest
})
break
;
case
'
PersistentVolumeClaim
'
:
...
...
@@ -73,8 +71,8 @@ const serviceCreate = async (data) => {
pvc
=
await
client
.
api
.
v1
.
namespaces
(
namespace
).
persistentvolumeclaims
.
get
()
pvc
=
pvc
.
body
.
items
.
filter
(
item
=>
item
.
metadata
.
name
===
pvcName
)
if
(
!
pvc
.
length
)
{
logger
.
info
(
'
创建pvc
'
,
JSON
.
stringify
(
jsonObj
))
await
client
.
api
.
v1
.
namespaces
(
namespace
).
persistentvolumeclaims
.
post
({
body
:
jsonObj
})
logger
.
info
(
'
创建pvc
'
,
JSON
.
stringify
(
manifest
))
await
client
.
api
.
v1
.
namespaces
(
namespace
).
persistentvolumeclaims
.
post
({
body
:
manifest
})
}
break
;
...
...
@@ -93,15 +91,15 @@ const imageUpdate = async (data) => {
await
client
.
apis
.
apps
.
v1beta1
.
namespaces
(
namespace
).
deployments
(
serviceName
).
patch
({
body
:
updateObj
})
}
const
service
Update
=
async
(
data
)
=>
{
const
deploy
Update
=
async
(
data
)
=>
{
const
{
namespace
,
serviceName
}
=
data
const
yaml
Array
=
makeManifest
(
data
)
const
manifest
Array
=
makeManifest
(
data
)
for
(
const
item
of
yaml
Array
)
{
const
jsonObj
=
yaml
.
load
(
item
);
if
(
jsonObj
.
kind
===
'
Deployment
'
)
{
logger
.
info
(
'
Deployment:
'
,
JSON
.
stringify
(
jsonObj
))
await
client
.
apis
.
apps
.
v1beta1
.
namespaces
(
namespace
).
deployments
(
serviceName
).
put
({
body
:
jsonObj
})
for
(
const
item
of
manifest
Array
)
{
const
manifest
=
yaml
.
load
(
item
);
if
(
manifest
.
kind
===
'
Deployment
'
)
{
logger
.
info
(
'
更新deploy:
'
,
JSON
.
stringify
(
manifest
))
await
client
.
apis
.
apps
.
v1beta1
.
namespaces
(
namespace
).
deployments
(
serviceName
).
put
({
body
:
manifest
})
}
}
}
...
...
@@ -281,7 +279,7 @@ module.exports = {
getPods
,
podGetstatus
,
serviceCreate
,
service
Update
,
deploy
Update
,
serviceRestart
,
serviceDelete
,
imageUpdate
,
...
...
serviceTemplate/resourceLimit.js
View file @
0892b50a
...
...
@@ -115,6 +115,11 @@ const defaultJava = {
cpu
:
cpuV3
,
}
projectConfig
.
baitiao
=
{
memory
:
memoryV3
,
cpu
:
cpuV3
,
}
projectConfig
[
'
cash-loan-flow
'
]
=
projectConfig
[
'
gu-bei
'
]
=
projectConfig
[
'
merchant-backend
'
]
=
projectConfig
[
'
xyqb-mall
'
]
=
projectConfig
.
xyqb
=
{
memory
:
memoryV3
,
cpu
:
cpuV4
,
...
...
yamls/java.yaml
View file @
0892b50a
...
...
@@ -39,6 +39,7 @@ spec:
labels
:
qcloud-app
:
{{
serviceName
}}
type
:
{{
label
}}
mock
:
{{
mock
}}
spec
:
terminationGracePeriodSeconds
:
0
containers
:
...
...
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