Commit 6ba645c7 authored by xuezj's avatar xuezj

修改 内存大户特别对待

parent 40431d10
...@@ -54,11 +54,31 @@ const createService = async (ctx) => { ...@@ -54,11 +54,31 @@ const createService = async (ctx) => {
data.system_name = serviceName data.system_name = serviceName
} }
const template = templates[type].replace(/{{([A-Za-z0-9_]+)}}/g, function () { // java 增加内存限制
if (data[arguments[1]] === undefined) { if (type === 'java') {
data.resources = {
cpu: {
request: 10,
limit: 1000,
},
memory: {
request: 100,
limit: 1024,
}
}
const special = ['xyqb', 'xyqb-user2']
if (special.includes(serviceName)) {
data.resources.memory.request = 600
}
}
const template = templates[type].replace(/{{([A-Za-z0-9_\.]+)}}/g, function () {
console.log( arguments[1])
if (_.get(data, arguments[1], null) === null) {
throw new Error(`缺少模板所需变量: ${arguments[1]}`) throw new Error(`缺少模板所需变量: ${arguments[1]}`)
} }
return data[arguments[1]] return _.get(data, arguments[1])
}) })
const params = yaml.load(template) const params = yaml.load(template)
await ctx.cluster.service_create(params, label) await ctx.cluster.service_create(params, label)
......
...@@ -14,7 +14,7 @@ containers.0.envs.0.value: {{system_name}} ...@@ -14,7 +14,7 @@ containers.0.envs.0.value: {{system_name}}
containers.0.envs.1.name: NAMESPACE containers.0.envs.1.name: NAMESPACE
containers.0.envs.1.value: {{namespace}} containers.0.envs.1.value: {{namespace}}
containers.0.cpu: 10 containers.0.cpu: {{resources.cpu.request}}
containers.0.cpuLimits: 1000 containers.0.cpuLimits: {{resources.cpu.limit}}
containers.0.memory: 100 containers.0.memory: {{resources.memory.request}}
containers.0.memoryLimits: 1024 containers.0.memoryLimits: {{resources.memory.limit}}
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