Commit 917f25a5 authored by 智勇's avatar 智勇

name修改为字符串

parent 60464d13
...@@ -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 = {
......
...@@ -13,7 +13,7 @@ spec: ...@@ -13,7 +13,7 @@ spec:
--- ---
apiVersion: extensions/v1beta1 apiVersion: apps/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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment