Commit fbd45b87 authored by 智勇's avatar 智勇

暂存

parent 1c73cc60
...@@ -47,31 +47,34 @@ router.get('/', async (ctx) => { ...@@ -47,31 +47,34 @@ router.get('/', async (ctx) => {
const createService = async (ctx) => { const createService = async (ctx) => {
const { const {
type, serviceName, namespace, image, system_name, domain, label, debug, type, serviceName, namespace, system_name, domain, label,
} = ctx.request.body } = ctx.request.body
logger.info('创建服务', ctx.request.body) logger.info('创建服务', ctx.request.body)
if (label === 'base') {
await serviceCreate(namespace, serviceName, image, label) // 资源限制
const resources = projectConfig[serviceName] || defaultConfig[type]
logger.info('资源限制', JSON.stringify(resources))
const data = ctx.request.body
data.resources = resources
if (label === 'base' || label === 'ui' || label === 'node') {
await serviceCreate(data)
if (label !== 'base') {
if (serviceName === 'xyqb-user2') {
await ingressCreate(namespace, 'xyqb-user2-2', 'passportapi2')
}
await ingressCreate(namespace, serviceName, domain)
}
ctx.body = ctx.ok('创建成功') ctx.body = ctx.ok('创建成功')
return return
} }
const data = {
serviceName,
namespace,
image,
system_name,
debug,
}
if (!system_name) { if (!system_name) {
// ui abTest的时候不一样 // ui abTest的时候不一样
data.system_name = serviceName data.system_name = serviceName
} }
// 资源限制
const resources = projectConfig[data.system_name] || defaultConfig[type]
logger.info('资源限制', JSON.stringify(resources))
data.resources = resources
const template = templates[type].replace(/{{([A-Za-z0-9_\.]+)}}/g, function () { const template = templates[type].replace(/{{([A-Za-z0-9_\.]+)}}/g, function () {
if (_.get(data, arguments[1], null) === null) { if (_.get(data, arguments[1], null) === null) {
throw new Error(`缺少模板所需变量: ${arguments[1]}`) throw new Error(`缺少模板所需变量: ${arguments[1]}`)
...@@ -115,6 +118,7 @@ router.post('/details', async (ctx) => { ...@@ -115,6 +118,7 @@ router.post('/details', async (ctx) => {
const data = await ctx.cluster.service_get(ctx.request.body.serviceName, ctx.request.body.namespace) const data = await ctx.cluster.service_get(ctx.request.body.serviceName, ctx.request.body.namespace)
ctx.body = ctx.ok(Object.assign({}, data, { lanIp })) ctx.body = ctx.ok(Object.assign({}, data, { lanIp }))
}) })
router.post('/delete', async (ctx) => { router.post('/delete', async (ctx) => {
await ctx.cluster.service_delete(ctx.request.body.serviceName, ctx.request.body.namespace) await ctx.cluster.service_delete(ctx.request.body.serviceName, ctx.request.body.namespace)
if (ctx.request.body.serviceName === 'xyqb-user2') { if (ctx.request.body.serviceName === 'xyqb-user2') {
......
...@@ -15,15 +15,9 @@ const client = new Client({ ...@@ -15,15 +15,9 @@ const client = new Client({
const serviceGet = async (namespace, serviceName) => client.api.v1.namespaces(namespace).services(serviceName).get() const serviceGet = async (namespace, serviceName) => client.api.v1.namespaces(namespace).services(serviceName).get()
const podGet = async namespace => client.api.v1.namespaces(namespace).pods.get() const podGet = async namespace => client.api.v1.namespaces(namespace).pods.get()
const serviceCreate = async (namespace, serviceName, image) => { const serviceCreate = async (data) => {
const data = { const { type, namespace, serviceName } = data
namespace, const yamlManifest = yamls[type].replace(/{{([A-Za-z0-9_\.]+)}}/g, function () {
app: serviceName,
image,
}
const pvcName = `${serviceName}-${namespace}`
const yamlManifest = yamls[serviceName].replace(/{{([A-Za-z0-9_\.]+)}}/g, function () {
if (_.get(data, arguments[1], null) === null) { if (_.get(data, arguments[1], null) === null) {
throw new Error(`缺少模板所需变量: ${arguments[1]}`) throw new Error(`缺少模板所需变量: ${arguments[1]}`)
} }
...@@ -34,7 +28,10 @@ const serviceCreate = async (namespace, serviceName, image) => { ...@@ -34,7 +28,10 @@ const serviceCreate = async (namespace, serviceName, image) => {
for (const item of yamlArray) { for (const item of yamlArray) {
const jsonObj = yaml.load(item); const jsonObj = yaml.load(item);
console.log(JSON.stringify(jsonObj))
let pvc let pvc
let pvcName
switch (jsonObj.kind) { switch (jsonObj.kind) {
case 'Service': case 'Service':
...@@ -46,6 +43,7 @@ const serviceCreate = async (namespace, serviceName, image) => { ...@@ -46,6 +43,7 @@ const serviceCreate = async (namespace, serviceName, image) => {
break; break;
case 'PersistentVolumeClaim': case 'PersistentVolumeClaim':
pvcName = `${serviceName}-${namespace}`
pvc = await client.api.v1.namespaces(namespace).persistentvolumeclaims.get() pvc = await client.api.v1.namespaces(namespace).persistentvolumeclaims.get()
pvc = pvc.body.items.filter(item => item.metadata.name === pvcName) pvc = pvc.body.items.filter(item => item.metadata.name === pvcName)
if (!pvc.length) { if (!pvc.length) {
......
const logger = require('log4js').getLogger('error') const logger = require('koa-log4').getLogger('error')
module.exports = function () { module.exports = function () {
return async function (ctx, next) { return async function (ctx, next) {
......
...@@ -178,14 +178,6 @@ ...@@ -178,14 +178,6 @@
"integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
"dev": true "dev": true
}, },
"async": {
"version": "2.6.2",
"resolved": "http://npmprivate.quantgroups.com/async/-/async-2.6.2.tgz",
"integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==",
"requires": {
"lodash": "^4.17.11"
}
},
"async-each": { "async-each": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "http://registry.npm.taobao.org/async-each/download/async-each-1.0.1.tgz", "resolved": "http://registry.npm.taobao.org/async-each/download/async-each-1.0.1.tgz",
...@@ -704,11 +696,6 @@ ...@@ -704,11 +696,6 @@
"assert-plus": "^1.0.0" "assert-plus": "^1.0.0"
} }
}, },
"date-format": {
"version": "2.0.0",
"resolved": "http://npmprivate.quantgroups.com/date-format/-/date-format-2.0.0.tgz",
"integrity": "sha512-M6UqVvZVgFYqZL1SfHsRGIQSz3ZL+qgbsV5Lp1Vj61LZVYuEwcMXYay7DRDtYs2HQQBK5hQtQ0fD9aEJ89V0LA=="
},
"debug": { "debug": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "http://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz", "resolved": "http://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz",
...@@ -1424,7 +1411,8 @@ ...@@ -1424,7 +1411,8 @@
"flatted": { "flatted": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "http://npmprivate.quantgroups.com/flatted/-/flatted-2.0.0.tgz", "resolved": "http://npmprivate.quantgroups.com/flatted/-/flatted-2.0.0.tgz",
"integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==" "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==",
"dev": true
}, },
"fluent-openapi": { "fluent-openapi": {
"version": "1.0.0", "version": "1.0.0",
...@@ -1478,16 +1466,6 @@ ...@@ -1478,16 +1466,6 @@
"readable-stream": "^2.0.0" "readable-stream": "^2.0.0"
} }
}, },
"fs-extra": {
"version": "7.0.1",
"resolved": "http://npmprivate.quantgroups.com/fs-extra/-/fs-extra-7.0.1.tgz",
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"fs.realpath": { "fs.realpath": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "http://npmprivate.quantgroups.com/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "http://npmprivate.quantgroups.com/fs.realpath/-/fs.realpath-1.0.0.tgz",
...@@ -2126,7 +2104,8 @@ ...@@ -2126,7 +2104,8 @@
"graceful-fs": { "graceful-fs": {
"version": "4.1.15", "version": "4.1.15",
"resolved": "http://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.1.15.tgz", "resolved": "http://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.1.15.tgz",
"integrity": "sha1-/7cD4QZuig7qpMi4C6klPu77+wA=" "integrity": "sha1-/7cD4QZuig7qpMi4C6klPu77+wA=",
"dev": true
}, },
"har-schema": { "har-schema": {
"version": "2.0.0", "version": "2.0.0",
...@@ -2726,14 +2705,6 @@ ...@@ -2726,14 +2705,6 @@
"resolved": "http://registry.npm.taobao.org/json-stringify-safe/download/json-stringify-safe-5.0.1.tgz", "resolved": "http://registry.npm.taobao.org/json-stringify-safe/download/json-stringify-safe-5.0.1.tgz",
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
}, },
"jsonfile": {
"version": "4.0.0",
"resolved": "http://npmprivate.quantgroups.com/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"requires": {
"graceful-fs": "^4.1.6"
}
},
"jsprim": { "jsprim": {
"version": "1.4.1", "version": "1.4.1",
"resolved": "http://registry.npm.taobao.org/jsprim/download/jsprim-1.4.1.tgz", "resolved": "http://registry.npm.taobao.org/jsprim/download/jsprim-1.4.1.tgz",
...@@ -2973,18 +2944,6 @@ ...@@ -2973,18 +2944,6 @@
"resolved": "http://npmprivate.quantgroups.com/lodash.merge/-/lodash.merge-4.6.1.tgz", "resolved": "http://npmprivate.quantgroups.com/lodash.merge/-/lodash.merge-4.6.1.tgz",
"integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==" "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ=="
}, },
"log4js": {
"version": "4.0.2",
"resolved": "http://npmprivate.quantgroups.com/log4js/-/log4js-4.0.2.tgz",
"integrity": "sha512-KE7HjiieVDPPdveA3bJZSuu0n8chMkFl8mIoisBFxwEJ9FmXe4YzNuiqSwYUiR1K8q8/5/8Yd6AClENY1RA9ww==",
"requires": {
"date-format": "^2.0.0",
"debug": "^3.1.0",
"flatted": "^2.0.0",
"rfdc": "^1.1.2",
"streamroller": "^1.0.1"
}
},
"long": { "long": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "http://npmprivate.quantgroups.com/long/-/long-4.0.0.tgz", "resolved": "http://npmprivate.quantgroups.com/long/-/long-4.0.0.tgz",
...@@ -4325,18 +4284,6 @@ ...@@ -4325,18 +4284,6 @@
"resolved": "http://registry.npm.taobao.org/statuses/download/statuses-1.5.0.tgz", "resolved": "http://registry.npm.taobao.org/statuses/download/statuses-1.5.0.tgz",
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
}, },
"streamroller": {
"version": "1.0.3",
"resolved": "http://npmprivate.quantgroups.com/streamroller/-/streamroller-1.0.3.tgz",
"integrity": "sha512-P7z9NwP51EltdZ81otaGAN3ob+/F88USJE546joNq7bqRNTe6jc74fTBDyynxP4qpIfKlt/CesEYicuMzI0yJg==",
"requires": {
"async": "^2.6.1",
"date-format": "^2.0.0",
"debug": "^3.1.0",
"fs-extra": "^7.0.0",
"lodash": "^4.17.10"
}
},
"strict-uri-encode": { "strict-uri-encode": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "http://npmprivate.quantgroups.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", "resolved": "http://npmprivate.quantgroups.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz",
...@@ -4664,11 +4611,6 @@ ...@@ -4664,11 +4611,6 @@
"crypto-random-string": "^1.0.0" "crypto-random-string": "^1.0.0"
} }
}, },
"universalify": {
"version": "0.1.2",
"resolved": "http://npmprivate.quantgroups.com/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
},
"unpipe": { "unpipe": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "http://registry.npm.taobao.org/unpipe/download/unpipe-1.0.0.tgz", "resolved": "http://registry.npm.taobao.org/unpipe/download/unpipe-1.0.0.tgz",
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
"koa-router": "^7.4.0", "koa-router": "^7.4.0",
"kubernetes-client": "^6.3.2", "kubernetes-client": "^6.3.2",
"lodash": "^4.17.11", "lodash": "^4.17.11",
"log4js": "^4.0.2",
"lru-cache": "^5.1.1", "lru-cache": "^5.1.1",
"request": "^2.88.0" "request": "^2.88.0"
}, },
......
...@@ -4,10 +4,16 @@ const mysql = fs.readFileSync('yamls/mysql.pvc.yaml', 'utf8') ...@@ -4,10 +4,16 @@ const mysql = fs.readFileSync('yamls/mysql.pvc.yaml', 'utf8')
const redis = fs.readFileSync('yamls/redis.pvc.yaml', 'utf8') const redis = fs.readFileSync('yamls/redis.pvc.yaml', 'utf8')
const rabbitmq = fs.readFileSync('yamls/rabbitmq.pvc.yaml', 'utf8') const rabbitmq = fs.readFileSync('yamls/rabbitmq.pvc.yaml', 'utf8')
const zookeeper = fs.readFileSync('yamls/zookeeper.pvc.yaml', 'utf8') const zookeeper = fs.readFileSync('yamls/zookeeper.pvc.yaml', 'utf8')
const ui = fs.readFileSync('yamls/ui.node.yaml', 'utf8')
const node = fs.readFileSync('yamls/ui.node.yaml', 'utf8')
const java = fs.readFileSync('yamls/java.yaml', 'utf8')
module.exports = { module.exports = {
mysql, mysql,
redis, redis,
rabbitmq, rabbitmq,
zookeeper, zookeeper,
ui,
node,
java,
} }
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: {{serviceName}}
namespace: {{namespace}}
labels:
type: {{label}}
qcloud-app: {{serviceName}}
spec:
replicas: 1
selector:
matchLabels:
qcloud-app: {{serviceName}}
strategy:
type: Recreate
template:
metadata:
labels:
qcloud-app: {{serviceName}}
spec:
revisionHistoryLimit: 1
containers:
- name: {{serviceName}}
image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: Always
volumeMounts:
env:
- name: NAMESPACE
value: {{namespace}}
- name: DEBUG
value: {{debug}}
resources:
requests:
cpu: {{resources.cpu.request}}m
memory: {{resources.memory.request}}Mi
limits:
cpu: {{resources.cpu.limit}}m
memory: {{resources.memory.limit}}Mi
restartPolicy: Always
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: qcloudregistrykey
- name: tencenthubkey
---
apiVersion: v1
kind: Service
metadata:
labels:
type: base
qcloud-app: {{serviceName}}
name: {{serviceName}}
namespace: {{namespace}}
spec:
type: NodePort
ports:
- name: http
port: 80
targetPort: 80
selector:
qcloud-app: {{serviceName}}
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: {{app}}-{{namespace}} name: {{serviceName}}-{{namespace}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
storageClassName: cbs storageClassName: cbs
...@@ -18,26 +18,26 @@ kind: Deployment ...@@ -18,26 +18,26 @@ kind: Deployment
metadata: metadata:
labels: labels:
type: base type: base
qcloud-app: {{app}} qcloud-app: {{serviceName}}
name: {{app}} name: {{serviceName}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
replicas: 1 replicas: 1
revisionHistoryLimit: 1 revisionHistoryLimit: 1
selector: selector:
matchLabels: matchLabels:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
strategy: strategy:
type: Recreate type: Recreate
template: template:
metadata: metadata:
labels: labels:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
spec: spec:
containers: containers:
- image: ccr.ccs.tencentyun.com/{{image}} - image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: Always imagePullPolicy: Always
name: {{app}} name: {{serviceName}}
resources: resources:
requests: requests:
memory: 400Mi memory: 400Mi
...@@ -56,11 +56,11 @@ spec: ...@@ -56,11 +56,11 @@ spec:
value: qa value: qa
volumeMounts: volumeMounts:
- mountPath: "/var/lib/mysql" - mountPath: "/var/lib/mysql"
name: {{app}} name: {{serviceName}}
volumes: volumes:
- name: {{app}} - name: {{serviceName}}
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{app}}-{{namespace}} claimName: {{serviceName}}-{{namespace}}
imagePullSecrets: imagePullSecrets:
- name: qcloudregistrykey - name: qcloudregistrykey
- name: tencenthubkey - name: tencenthubkey
...@@ -74,8 +74,8 @@ kind: Service ...@@ -74,8 +74,8 @@ kind: Service
metadata: metadata:
labels: labels:
type: base type: base
qcloud-app: {{app}} qcloud-app: {{serviceName}}
name: {{app}} name: {{serviceName}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
type: NodePort type: NodePort
...@@ -84,4 +84,4 @@ spec: ...@@ -84,4 +84,4 @@ spec:
port: 3306 port: 3306
targetPort: 3306 targetPort: 3306
selector: selector:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: {{app}}-{{namespace}} name: {{serviceName}}-{{namespace}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
storageClassName: cbs storageClassName: cbs
...@@ -18,28 +18,28 @@ kind: Deployment ...@@ -18,28 +18,28 @@ kind: Deployment
metadata: metadata:
labels: labels:
type: base type: base
qcloud-app: {{app}} qcloud-app: {{serviceName}}
name: {{app}} name: {{serviceName}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
replicas: 1 replicas: 1
revisionHistoryLimit: 1 revisionHistoryLimit: 1
selector: selector:
matchLabels: matchLabels:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
strategy: strategy:
type: Recreate type: Recreate
template: template:
metadata: metadata:
labels: labels:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
spec: spec:
# hostname固定,容器重置后数据持久化才能正常 # hostname固定,容器重置后数据持久化才能正常
hostname: {{app}}-{{namespace}} hostname: {{serviceName}}-{{namespace}}
containers: containers:
- image: ccr.ccs.tencentyun.com/{{image}} - image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
name: {{app}} name: {{serviceName}}
resources: resources:
requests: requests:
memory: 100Mi memory: 100Mi
...@@ -54,13 +54,13 @@ spec: ...@@ -54,13 +54,13 @@ spec:
value: qatest value: qatest
# 数据持久化 # 数据持久化
volumeMounts: volumeMounts:
- name: {{app}} - name: {{serviceName}}
mountPath: "/var/lib/rabbitmq" mountPath: "/var/lib/rabbitmq"
volumes: volumes:
- name: {{app}} - name: {{serviceName}}
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{app}}-{{namespace}} claimName: {{serviceName}}-{{namespace}}
imagePullSecrets: imagePullSecrets:
- name: qcloudregistrykey - name: qcloudregistrykey
- name: tencenthubkey - name: tencenthubkey
...@@ -74,8 +74,8 @@ kind: Service ...@@ -74,8 +74,8 @@ kind: Service
metadata: metadata:
labels: labels:
type: base type: base
qcloud-app: {{app}} qcloud-app: {{serviceName}}
name: {{app}} name: {{serviceName}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
type: NodePort type: NodePort
...@@ -89,4 +89,4 @@ spec: ...@@ -89,4 +89,4 @@ spec:
port: 15672 port: 15672
targetPort: 15672 targetPort: 15672
selector: selector:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: {{app}}-{{namespace}} name: {{serviceName}}-{{namespace}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
storageClassName: cbs storageClassName: cbs
...@@ -18,26 +18,26 @@ kind: Deployment ...@@ -18,26 +18,26 @@ kind: Deployment
metadata: metadata:
labels: labels:
type: base type: base
qcloud-app: {{app}} qcloud-app: {{serviceName}}
name: {{app}} name: {{serviceName}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
replicas: 1 replicas: 1
revisionHistoryLimit: 1 revisionHistoryLimit: 1
selector: selector:
matchLabels: matchLabels:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
strategy: strategy:
type: Recreate type: Recreate
template: template:
metadata: metadata:
labels: labels:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
spec: spec:
containers: containers:
- image: ccr.ccs.tencentyun.com/{{image}} - image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: Always imagePullPolicy: Always
name: {{app}} name: {{serviceName}}
resources: resources:
requests: requests:
memory: 40Mi memory: 40Mi
...@@ -47,11 +47,11 @@ spec: ...@@ -47,11 +47,11 @@ spec:
cpu: 500m cpu: 500m
volumeMounts: volumeMounts:
- mountPath: "/data" - mountPath: "/data"
name: {{app}} name: {{serviceName}}
volumes: volumes:
- name: {{app}} - name: {{serviceName}}
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{app}}-{{namespace}} claimName: {{serviceName}}-{{namespace}}
imagePullSecrets: imagePullSecrets:
- name: qcloudregistrykey - name: qcloudregistrykey
- name: tencenthubkey - name: tencenthubkey
...@@ -65,8 +65,8 @@ kind: Service ...@@ -65,8 +65,8 @@ kind: Service
metadata: metadata:
labels: labels:
type: base type: base
qcloud-app: {{app}} qcloud-app: {{serviceName}}
name: {{app}} name: {{serviceName}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
type: NodePort type: NodePort
...@@ -87,4 +87,4 @@ spec: ...@@ -87,4 +87,4 @@ spec:
port: 6383 port: 6383
targetPort: 6383 targetPort: 6383
selector: selector:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: {{serviceName}}
namespace: {{namespace}}
labels:
type: {{label}}
qcloud-app: {{serviceName}}
spec:
replicas: 1
selector:
matchLabels:
qcloud-app: {{serviceName}}
strategy:
type: Recreate
template:
metadata:
labels:
qcloud-app: {{serviceName}}
spec:
revisionHistoryLimit: 1
containers:
- name: {{serviceName}}
image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: Always
volumeMounts:
env:
- name: NAMESPACE
value: {{namespace}}
- name: DEBUG
value: {{debug}}
resources:
requests:
cpu: {{resources.cpu.request}}m
memory: {{resources.memory.request}}Mi
limits:
cpu: {{resources.cpu.limit}}m
memory: {{resources.memory.limit}}Mi
restartPolicy: Always
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: qcloudregistrykey
- name: tencenthubkey
---
apiVersion: v1
kind: Service
metadata:
labels:
type: base
qcloud-app: {{serviceName}}
name: {{serviceName}}
namespace: {{namespace}}
spec:
type: NodePort
ports:
- name: http
port: 80
targetPort: 80
selector:
qcloud-app: {{serviceName}}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{app}}
namespace: {{namespace}}
labels:
qcloud-app: {{app}}
spec:
replicas: 1
selector:
matchLabels:
qcloud-app: {{app}}
strategy:
type: Recreate
template:
metadata:
labels:
qcloud-app: {{app}}
spec:
revisionHistoryLimit: 2
containers:
- image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: Always
name: {{app}}
resources:
requests:
memory: 64Mi
limits:
memory: 256Mi
securityContext:
privileged: false
terminationMessagePath: /dev/termination-log
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
ports:
- containerPort: 80
restartPolicy: Always
dnsPolicy: ClusterFirst
volumes:
- name: logs-vol
emptyDir: {}
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: {{app}}-{{namespace}} name: {{serviceName}}-{{namespace}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
storageClassName: cbs storageClassName: cbs
...@@ -18,26 +18,26 @@ kind: Deployment ...@@ -18,26 +18,26 @@ kind: Deployment
metadata: metadata:
labels: labels:
type: base type: base
qcloud-app: {{app}} qcloud-app: {{serviceName}}
name: {{app}} name: {{serviceName}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
replicas: 1 replicas: 1
revisionHistoryLimit: 1 revisionHistoryLimit: 1
selector: selector:
matchLabels: matchLabels:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
strategy: strategy:
type: Recreate type: Recreate
template: template:
metadata: metadata:
labels: labels:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
spec: spec:
containers: containers:
- image: ccr.ccs.tencentyun.com/{{image}} - image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: Always imagePullPolicy: Always
name: {{app}} name: {{serviceName}}
resources: resources:
requests: requests:
memory: 100Mi memory: 100Mi
...@@ -47,16 +47,16 @@ spec: ...@@ -47,16 +47,16 @@ spec:
cpu: 500m cpu: 500m
volumeMounts: volumeMounts:
- mountPath: "/var/lib/zookeeper" - mountPath: "/var/lib/zookeeper"
name: {{app}} name: {{serviceName}}
env: env:
- name: ZOO_USER - name: ZOO_USER
value: zookeeper value: zookeeper
# - name: ZOO_PORT # - name: ZOO_PORT
# value: 2181 # value: 2181
volumes: volumes:
- name: {{app}} - name: {{serviceName}}
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{app}}-{{namespace}} claimName: {{serviceName}}-{{namespace}}
imagePullSecrets: imagePullSecrets:
- name: qcloudregistrykey - name: qcloudregistrykey
- name: tencenthubkey - name: tencenthubkey
...@@ -71,8 +71,8 @@ kind: Service ...@@ -71,8 +71,8 @@ kind: Service
metadata: metadata:
labels: labels:
type: base type: base
qcloud-app: {{app}} qcloud-app: {{serviceName}}
name: {{app}} name: {{serviceName}}
namespace: {{namespace}} namespace: {{namespace}}
spec: spec:
type: NodePort type: NodePort
...@@ -84,4 +84,4 @@ spec: ...@@ -84,4 +84,4 @@ spec:
port: 9090 port: 9090
targetPort: 9090 targetPort: 9090
selector: selector:
qcloud-app: {{app}} qcloud-app: {{serviceName}}
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