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
9dbf3e85
Commit
9dbf3e85
authored
Sep 12, 2019
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建ns支持多集群
parent
19ac4619
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
47 deletions
+77
-47
service.js
kubeService/service.js
+52
-47
index.js
yamls/index.js
+2
-0
tencenthubkey.yaml
yamls/tencenthubkey.yaml
+23
-0
No files found.
kubeService/service.js
View file @
9dbf3e85
...
@@ -25,6 +25,31 @@ const getAllNamespace = async (client) => {
...
@@ -25,6 +25,31 @@ const getAllNamespace = async (client) => {
})
})
return
data
return
data
}
}
const
makeManifest
=
(
data
)
=>
{
if
(
!
data
.
debug
)
{
data
.
debug
=
'
"0"
'
}
if
(
!
data
.
mock
)
{
data
.
mock
=
'
"0"
'
}
if
(
data
.
label
===
'
java
'
)
{
data
.
serviceType
=
data
.
debug
===
'
"0"
'
?
'
ClusterIP
'
:
'
NodePort
'
}
const
yamlManifest
=
yamls
[
data
.
type
].
replace
(
/{{
([
A-Za-z0-9_
\.]
+
)
}}/g
,
function
()
{
if
(
_
.
get
(
data
,
arguments
[
1
],
null
)
===
null
)
{
throw
new
Error
(
`缺少模板所需变量:
${
arguments
[
1
]}
`
)
}
return
_
.
get
(
data
,
arguments
[
1
])
})
const
manifestArray
=
yamlManifest
.
split
(
'
---
'
)
return
manifestArray
}
const
createNamespace
=
async
(
client
,
name
,
description
)
=>
{
const
createNamespace
=
async
(
client
,
name
,
description
)
=>
{
const
parmas
=
{
const
parmas
=
{
apiVersion
:
'
v1
'
,
apiVersion
:
'
v1
'
,
...
@@ -46,33 +71,20 @@ const createNamespace = async (client, name, description) => {
...
@@ -46,33 +71,20 @@ const createNamespace = async (client, name, description) => {
],
],
},
},
}
}
const
res
=
await
client
.
api
.
v1
.
namespaces
.
post
({
body
:
parmas
})
logger
.
info
(
'
创建namespace
'
,
name
,
JSON
.
stringify
(
parmas
))
return
res
await
client
.
api
.
v1
.
namespaces
.
post
({
body
:
parmas
})
}
const
makeManifest
=
(
data
)
=>
{
if
(
!
data
.
debug
)
{
data
.
debug
=
'
"0"
'
}
if
(
!
data
.
mock
)
{
const
manifestArray
=
makeManifest
({
namespace
:
name
,
type
:
'
tencenthubkey
'
})
data
.
mock
=
'
"1"
'
for
(
const
item
of
manifestArray
)
{
}
const
manifest
=
yaml
.
load
(
item
);
logger
.
info
(
'
创建secret
'
,
JSON
.
stringify
(
manifest
))
if
(
data
.
label
===
'
java
'
)
{
await
client
.
api
.
v1
.
namespaces
(
name
)
data
.
serviceType
=
data
.
debug
===
'
"0"
'
?
'
ClusterIP
'
:
'
NodePort
'
.
secrets
.
post
({
body
:
manifest
})
}
}
const
yamlManifest
=
yamls
[
data
.
type
].
replace
(
/{{
([
A-Za-z0-9_
\.]
+
)
}}/g
,
function
()
{
if
(
_
.
get
(
data
,
arguments
[
1
],
null
)
===
null
)
{
throw
new
Error
(
`缺少模板所需变量:
${
arguments
[
1
]}
`
)
}
return
_
.
get
(
data
,
arguments
[
1
])
})
const
manifestArray
=
yamlManifest
.
split
(
'
---
'
)
return
manifestArray
}
}
const
serviceCreate
=
async
(
cluster
,
client
,
data
)
=>
{
const
serviceCreate
=
async
(
cluster
,
client
,
data
)
=>
{
data
.
cluster
=
cluster
data
.
cluster
=
cluster
const
{
namespace
,
serviceName
}
=
data
const
{
namespace
,
serviceName
}
=
data
...
@@ -179,38 +191,31 @@ const formatServiceInfo = (obj) => {
...
@@ -179,38 +191,31 @@ const formatServiceInfo = (obj) => {
}
}
const
getPodStatus
=
(
podInfo
)
=>
{
const
getPodStatus
=
(
podInfo
)
=>
{
if
(
podInfo
.
status
.
phase
===
'
Pending
'
)
{
return
'
Pending
'
}
if
(
podInfo
.
status
.
conditions
)
{
for
(
const
item
of
podInfo
.
status
.
conditions
)
{
if
(
item
.
type
===
'
Initialized
'
&&
item
.
status
===
'
False
'
)
{
return
'
Initializing
'
}
if
(
item
.
type
===
'
PodScheduled
'
&&
item
.
status
===
'
False
'
)
{
return
'
PodScheduling
'
}
if
(
item
.
type
===
'
ContainersReady
'
&&
item
.
status
===
'
False
'
)
{
return
'
ContainerCreating
'
}
if
(
item
.
type
===
'
Ready
'
&&
item
.
status
===
'
False
'
)
{
return
'
Waiting
'
}
if
(
item
.
type
===
'
Ready
'
&&
item
.
status
===
'
True
'
)
{
return
'
Normal
'
}
}
}
if
(
podInfo
.
metadata
.
deletionTimestamp
)
{
if
(
podInfo
.
metadata
.
deletionTimestamp
)
{
return
'
Terminating
'
return
'
Terminating
'
}
}
let
status
if
(
!
podInfo
.
status
.
containerStatuses
)
{
status
=
'
Pending
'
}
else
{
if
(
podInfo
.
status
.
containerStatuses
[
0
].
state
.
waiting
)
{
status
=
'
ContainerCreating
'
}
if
(
podInfo
.
status
.
containerStatuses
[
0
].
state
.
running
&&
!
podInfo
.
status
.
containerStatuses
[
0
].
ready
)
{
status
=
'
Waiting
'
}
if
(
podInfo
.
status
.
containerStatuses
[
0
].
state
.
running
&&
podInfo
.
status
.
containerStatuses
[
0
].
ready
)
{
status
=
'
Normal
'
}
}
return
status
}
}
const
formatPodInfo
=
(
podInfo
)
=>
{
const
formatPodInfo
=
(
podInfo
)
=>
{
const
podStatus
=
getPodStatus
(
podInfo
)
const
podStatus
=
getPodStatus
(
podInfo
)
// for debug
// for debug
// if (podInfo.metadata.name.indexOf('
xyqb-user2
') !== -1) {
// if (podInfo.metadata.name.indexOf('
zookeeper
') !== -1) {
// console.log(1, podStatus, JSON.stringify(podInfo
.status.conditions
))
// console.log(1, podStatus, JSON.stringify(podInfo))
// }
// }
const
imageID
=
_
.
get
(
podInfo
.
status
.
containerStatuses
,
'
[0].imageID
'
,
''
)
const
imageID
=
_
.
get
(
podInfo
.
status
.
containerStatuses
,
'
[0].imageID
'
,
''
)
const
image
=
_
.
get
(
podInfo
.
spec
.
containers
,
'
[0].image
'
,
''
)
const
image
=
_
.
get
(
podInfo
.
spec
.
containers
,
'
[0].image
'
,
''
)
...
...
yamls/index.js
View file @
9dbf3e85
...
@@ -10,6 +10,7 @@ const ui = fs.readFileSync('yamls/ui.node.yaml', 'utf8')
...
@@ -10,6 +10,7 @@ const ui = fs.readFileSync('yamls/ui.node.yaml', 'utf8')
const
node
=
fs
.
readFileSync
(
'
yamls/ui.node.yaml
'
,
'
utf8
'
)
const
node
=
fs
.
readFileSync
(
'
yamls/ui.node.yaml
'
,
'
utf8
'
)
const
java
=
fs
.
readFileSync
(
'
yamls/java.yaml
'
,
'
utf8
'
)
const
java
=
fs
.
readFileSync
(
'
yamls/java.yaml
'
,
'
utf8
'
)
const
python
=
fs
.
readFileSync
(
'
yamls/python.yaml
'
,
'
utf8
'
)
const
python
=
fs
.
readFileSync
(
'
yamls/python.yaml
'
,
'
utf8
'
)
const
tencenthubkey
=
fs
.
readFileSync
(
'
yamls/tencenthubkey.yaml
'
,
'
utf8
'
)
module
.
exports
=
{
module
.
exports
=
{
mysql
,
mysql
,
...
@@ -22,4 +23,5 @@ module.exports = {
...
@@ -22,4 +23,5 @@ module.exports = {
node
,
node
,
java
,
java
,
python
,
python
,
tencenthubkey
,
}
}
yamls/tencenthubkey.yaml
0 → 100644
View file @
9dbf3e85
apiVersion
:
v1
data
:
.dockercfg
:
eyJodWIudGVuY2VudHl1bi5jb20iOnsidXNlcm5hbWUiOiIxMDAwMDg2MzIyNjkiLCJwYXNzd29yZCI6ImV5SmhiR2NpT2lKSVV6STFOaUlzSW5SNWNDSTZJa3BYVkNKOS5leUpsZUhBaU9qRTROelk1T0RZNE5UVXNJbXAwYVNJNkltVXdORGs1TVRKaExXVmpPVEV0TkdVeE5TMDVPRFF6TFdOa05URXlZV05sWXpGak1TSXNJbWxoZENJNk1UVTJNVFl5TmpnMU5Td2libUptSWpveE5UWXhOakkyT0RVMUxDSnpkV0lpT2lJeE1EQXdNRGcyTXpJeU5qa2lmUS5FY0NuclRSRG12MjFicHczdENld1pBdHhpMko0WEdEVHQwYUM2cDNKSGhNIiwiZW1haWwiOiIxMDAwMDg2MzIyNjlAcXEuY29tIiwiYXV0aCI6Ik1UQXdNREE0TmpNeU1qWTVPbVY1U21oaVIyTnBUMmxLU1ZWNlNURk9hVWx6U1c1U05XTkRTVFpKYTNCWVZrTktPUzVsZVVwc1pVaEJhVTlxUlRST2VsazFUMFJaTkU1VVZYTkpiWEF3WVZOSk5rbHRWWGRPUkdzMVRWUkthRXhYVm1wUFZFVjBUa2RWZUU1VE1EVlBSRkY2VEZkT2EwNVVSWGxaVjA1c1dYcEdhazFUU1hOSmJXeG9aRU5KTmsxVVZUSk5WRmw1VG1wbk1VNVRkMmxpYlVwdFNXcHZlRTVVV1hoT2Fra3lUMFJWTVV4RFNucGtWMGxwVDJsSmVFMUVRWGROUkdjeVRYcEplVTVxYTJsbVVTNUZZME51Y2xSU1JHMTJNakZpY0hjemRFTmxkMXBCZEhocE1rbzBXRWRFVkhRd1lVTTJjRE5LU0doTiJ9fQ==
kind
:
Secret
metadata
:
labels
:
qcloud-app
:
tencenthubkey
name
:
tencenthubkey
namespace
:
{{
namespace
}}
type
:
kubernetes.io/dockercfg
---
apiVersion
:
v1
data
:
.dockercfg
:
eyJjY3IuY2NzLnRlbmNlbnR5dW4uY29tIjp7InVzZXJuYW1lIjoiMTAwMDA4NjMyMjY5IiwicGFzc3dvcmQiOiJ7QXBwbGljYXRpb25Ub2tlbjo0MTM1NWY2OWQyY2U3ZWUyYmE2YjQxZmMxNzJlNzM0MH0iLCJlbWFpbCI6IjEwMDAwODYzMjI2OUBxcS5jb20iLCJhdXRoIjoiTVRBd01EQTROak15TWpZNU9udEJjSEJzYVdOaGRHbHZibFJ2YTJWdU9qUXhNelUxWmpZNVpESmpaVGRsWlRKaVlUWmlOREZtWXpFM01tVTNNelF3ZlE9PSJ9fQ==
kind
:
Secret
metadata
:
labels
:
qcloud-app
:
qcloudregistrykey
name
:
qcloudregistrykey
namespace
:
{{
namespace
}}
type
:
kubernetes.io/dockercfg
\ No newline at end of file
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