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
917f25a5
Commit
917f25a5
authored
May 16, 2019
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
name修改为字符串
parent
60464d13
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
10 deletions
+24
-10
service.js
kubeService/service.js
+21
-7
mysql.yaml
yamls/mysql.yaml
+3
-3
No files found.
kubeService/service.js
View file @
917f25a5
...
@@ -2,7 +2,7 @@ const path = require('path')
...
@@ -2,7 +2,7 @@ const path = require('path')
const
Client
=
require
(
'
kubernetes-client
'
).
Client
const
Client
=
require
(
'
kubernetes-client
'
).
Client
const
config
=
require
(
'
kubernetes-client
'
).
config
const
config
=
require
(
'
kubernetes-client
'
).
config
const
_
=
require
(
'
lodash
'
)
const
_
=
require
(
'
lodash
'
)
const
YAML
=
require
(
'
yamljs
'
);
const
yaml
=
require
(
'
js-yaml
'
)
const
yamls
=
require
(
'
../yamls
'
)
const
yamls
=
require
(
'
../yamls
'
)
const
client
=
new
Client
({
const
client
=
new
Client
({
...
@@ -27,15 +27,29 @@ const serviceCreate = async (namespace, serviceName, image) => {
...
@@ -27,15 +27,29 @@ const serviceCreate = async (namespace, serviceName, image) => {
}
}
return
_
.
get
(
data
,
arguments
[
1
])
return
_
.
get
(
data
,
arguments
[
1
])
})
})
const
nativeObject
=
YAML
.
load
(
yamlManifest
);
// console.log(1, nativeObject)
const
jsonstr
=
JSON
.
stringify
(
nativeObject
);
const
yamlArray
=
yamlManifest
.
split
(
'
---
'
)
const
jsonTemp
=
JSON
.
parse
(
jsonstr
,
null
);
yamlArray
.
forEach
(
async
(
item
)
=>
{
const
jsonObj
=
yaml
.
load
(
item
);
// jsonstr = JSON.parse(jsonstr, null);
switch
(
jsonObj
.
kind
)
{
client
.
api
.
v1
.
namespaces
(
namespace
).
services
.
post
({
body
:
jsonTemp
})
case
'
Service
'
:
await
client
.
api
.
v1
.
namespaces
(
namespace
).
services
.
post
({
body
:
jsonObj
})
break
;
case
'
Deployment
'
:
await
client
.
apis
.
apps
.
v1beta1
.
namespaces
(
namespace
).
deployments
.
post
({
body
:
jsonObj
})
break
;
case
'
PersistentVolumeClaim
'
:
await
client
.
api
.
v1
.
namespaces
(
namespace
).
persistentvolumeclaims
.
post
({
body
:
jsonObj
})
break
;
default
:
break
;
}
})
}
}
module
.
exports
=
{
module
.
exports
=
{
...
...
yamls/mysql.yaml
View file @
917f25a5
...
@@ -13,7 +13,7 @@ spec:
...
@@ -13,7 +13,7 @@ spec:
---
---
apiVersion
:
extension
s/v1beta1
apiVersion
:
app
s/v1beta1
kind
:
Deployment
kind
:
Deployment
metadata
:
metadata
:
labels
:
labels
:
...
@@ -59,7 +59,7 @@ spec:
...
@@ -59,7 +59,7 @@ spec:
volumes
:
volumes
:
-
name
:
mysql
-
name
:
mysql
persistentVolumeClaim
:
persistentVolumeClaim
:
claimName
:
pvc-mysql-default
claimName
:
mysql
imagePullSecrets
:
imagePullSecrets
:
-
name
:
qcloudregistrykey
-
name
:
qcloudregistrykey
-
name
:
tencenthubkey
-
name
:
tencenthubkey
...
@@ -79,7 +79,7 @@ metadata:
...
@@ -79,7 +79,7 @@ metadata:
spec
:
spec
:
type
:
NodePort
type
:
NodePort
ports
:
ports
:
-
name
:
3306
-
name
:
'
3306'
nodePort
:
0
nodePort
:
0
port
:
3306
port
:
3306
protocol
:
TCP
protocol
:
TCP
...
...
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