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

name修改为字符串

parent 60464d13
......@@ -2,7 +2,7 @@ const path = require('path')
const Client = require('kubernetes-client').Client
const config = require('kubernetes-client').config
const _ = require('lodash')
const YAML = require('yamljs');
const yaml = require('js-yaml')
const yamls = require('../yamls')
const client = new Client({
......@@ -27,15 +27,29 @@ const serviceCreate = async (namespace, serviceName, image) => {
}
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);
client.api.v1.namespaces(namespace).services.post({ body: jsonTemp })
switch (jsonObj.kind) {
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 = {
......
......@@ -13,7 +13,7 @@ spec:
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1beta1
kind: Deployment
metadata:
labels:
......@@ -59,7 +59,7 @@ spec:
volumes:
- name: mysql
persistentVolumeClaim:
claimName: pvc-mysql-default
claimName: mysql
imagePullSecrets:
- name: qcloudregistrykey
- name: tencenthubkey
......@@ -79,7 +79,7 @@ metadata:
spec:
type: NodePort
ports:
- name: 3306
- name: '3306'
nodePort: 0
port: 3306
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