Commit c671ba7d authored by 智勇's avatar 智勇

获取details单个属性

parent 3955248f
...@@ -91,11 +91,17 @@ router.post('/details', async (ctx) => { ...@@ -91,11 +91,17 @@ router.post('/details', async (ctx) => {
.required(), .required(),
type: ctx.Joi.string() type: ctx.Joi.string()
.required(), .required(),
key: ctx.Joi.string(),
})) }))
const req = ctx.request.body
const data = await getServiceDetail(ctx.client, ctx.request.body.namespace, ctx.request.body.serviceName, ctx.request.body.type) const data = await getServiceDetail(ctx.client, req.namespace, req.serviceName, req.type)
if (req.key && data[req.key]) {
ctx.body = data[req.key]
return
}
ctx.body = ctx.ok(data) ctx.body = ctx.ok(data)
}) })
router.post('/delete', async (ctx) => { router.post('/delete', async (ctx) => {
const { namespace, serviceName, podName } = ctx.request.body const { namespace, serviceName, podName } = ctx.request.body
const key = `${namespace}:${podName}#${serviceName}` const key = `${namespace}:${podName}#${serviceName}`
......
...@@ -101,10 +101,14 @@ const serviceCreate = async (cluterParams, client, data) => { ...@@ -101,10 +101,14 @@ const serviceCreate = async (cluterParams, client, data) => {
if (data.wechat === '"1"') { if (data.wechat === '"1"') {
manifest.spec.type = 'NodePort' manifest.spec.type = 'NodePort'
} }
logger.info('创建svc', JSON.stringify(manifest)) try {
await client.api.v1.namespaces(namespace) logger.info('创建svc', JSON.stringify(manifest))
.services await client.api.v1.namespaces(namespace)
.post({ body: manifest }) .services
.post({ body: manifest })
} catch (error) {
logger.warn(error.toString())
}
break; break;
case 'Deployment': case 'Deployment':
...@@ -340,10 +344,12 @@ const serviceDelete = async (client, namespace, name) => { ...@@ -340,10 +344,12 @@ const serviceDelete = async (client, namespace, name) => {
await client.apis.apps.v1beta1.namespaces(namespace) await client.apis.apps.v1beta1.namespaces(namespace)
.deployments(name) .deployments(name)
.delete() .delete()
logger.info('删除svc', namespace, name) if (!~name.indexOf('mysql')) {
await client.api.v1.namespaces(namespace) logger.info('删除svc', namespace, name)
.services(name) await client.api.v1.namespaces(namespace)
.delete() .services(name)
.delete()
}
} catch (error) { } catch (error) {
logger.warn(error.toString()) logger.warn(error.toString())
} }
...@@ -365,10 +371,12 @@ const replicaSetDelete = async (client, namespace, name) => { ...@@ -365,10 +371,12 @@ const replicaSetDelete = async (client, namespace, name) => {
} }
const pvcDelete = async (client, namespace, name) => { const pvcDelete = async (client, namespace, name) => {
try { try {
logger.info('删除pvc', namespace, name) if (!~name.indexOf('mysql')) {
await client.api.v1.namespaces(namespace) logger.info('删除pvc', namespace, name)
.persistentvolumeclaim(`${name}-${namespace}`) await client.api.v1.namespaces(namespace)
.delete() .persistentvolumeclaim(`${name}-${namespace}`)
.delete()
}
} catch (error) { } catch (error) {
logger.warn(error.toString()) logger.warn(error.toString())
} }
......
...@@ -13,6 +13,8 @@ spec: ...@@ -13,6 +13,8 @@ spec:
port: 80 port: 80
- name: '5005' - name: '5005'
port: 5005 port: 5005
# - name: '20880'
# port: 20880
selector: selector:
qcloud-app: {{serviceName}} qcloud-app: {{serviceName}}
...@@ -64,14 +66,14 @@ spec: ...@@ -64,14 +66,14 @@ spec:
value: {{debug}} value: {{debug}}
- name: MOCK - name: MOCK
value: {{mock}} value: {{mock}}
- name: DUBBO_PORT_TO_BIND # - name: DUBBO_PORT_TO_BIND
value: '80' # value: '80'
- name: DUBBO_PORT_TO_REGISTRY # - name: DUBBO_PORT_TO_REGISTRY
value: '80' # value: '80'
- name: DUBBO_IP_TO_REGISTRY # - name: DUBBO_IP_TO_REGISTRY
valueFrom: # valueFrom:
fieldRef: # fieldRef:
fieldPath: status.hostIP # fieldPath: status.hostIP
resources: resources:
requests: requests:
cpu: {{resources.cpuRequest}}m cpu: {{resources.cpuRequest}}m
......
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