Commit a87800a9 authored by 智勇's avatar 智勇

新增java readinessProbe

parent fbd45b87
...@@ -47,7 +47,7 @@ router.get('/', async (ctx) => { ...@@ -47,7 +47,7 @@ router.get('/', async (ctx) => {
const createService = async (ctx) => { const createService = async (ctx) => {
const { const {
type, serviceName, namespace, system_name, domain, label, type, serviceName, namespace, domain, label,
} = ctx.request.body } = ctx.request.body
logger.info('创建服务', ctx.request.body) logger.info('创建服务', ctx.request.body)
...@@ -58,17 +58,28 @@ const createService = async (ctx) => { ...@@ -58,17 +58,28 @@ const createService = async (ctx) => {
const data = ctx.request.body const data = ctx.request.body
data.resources = resources data.resources = resources
if (label === 'base' || label === 'ui' || label === 'node') { await serviceCreate(data)
await serviceCreate(data) if (label !== 'base') {
if (label !== 'base') { if (serviceName === 'xyqb-user2') {
if (serviceName === 'xyqb-user2') { await ingressCreate(namespace, 'xyqb-user2-2', 'passportapi2')
await ingressCreate(namespace, 'xyqb-user2-2', 'passportapi2')
}
await ingressCreate(namespace, serviceName, domain)
} }
ctx.body = ctx.ok('创建成功') await ingressCreate(namespace, serviceName, domain)
return
} }
ctx.body = ctx.ok('创建成功')
}
const createServiceTencent = async (ctx) => {
const {
type, serviceName, namespace, system_name, domain, label,
} = ctx.request.body
logger.info('创建服务', ctx.request.body)
// 资源限制
const resources = projectConfig[serviceName] || defaultConfig[type]
logger.info('资源限制', JSON.stringify(resources))
const data = ctx.request.body
data.resources = resources
if (!system_name) { if (!system_name) {
// ui abTest的时候不一样 // ui abTest的时候不一样
......
...@@ -3,6 +3,7 @@ const Client = require('kubernetes-client').Client ...@@ -3,6 +3,7 @@ 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('js-yaml') const yaml = require('js-yaml')
const logger = require('koa-log4').getLogger('kubeService')
const yamls = require('../yamls') const yamls = require('../yamls')
const client = new Client({ const client = new Client({
...@@ -28,7 +29,6 @@ const serviceCreate = async (data) => { ...@@ -28,7 +29,6 @@ const serviceCreate = async (data) => {
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 let pvcName
...@@ -39,6 +39,7 @@ const serviceCreate = async (data) => { ...@@ -39,6 +39,7 @@ const serviceCreate = async (data) => {
break; break;
case 'Deployment': case 'Deployment':
logger.info('Deployment:', JSON.stringify(jsonObj))
await client.apis.apps.v1beta1.namespaces(namespace).deployments.post({ body: jsonObj }) await client.apis.apps.v1beta1.namespaces(namespace).deployments.post({ body: jsonObj })
break; break;
......
...@@ -36,6 +36,15 @@ spec: ...@@ -36,6 +36,15 @@ spec:
limits: limits:
cpu: {{resources.cpu.limit}}m cpu: {{resources.cpu.limit}}m
memory: {{resources.memory.limit}}Mi memory: {{resources.memory.limit}}Mi
readinessProbe:
exec:
command:
- /home/quant_group/readyCheck.sh
initialDelaySeconds: 60
timeoutSeconds: 2
periodSeconds: 5
successThreshold: 1
failureThreshold: 20
restartPolicy: Always restartPolicy: Always
dnsPolicy: ClusterFirst dnsPolicy: ClusterFirst
imagePullSecrets: imagePullSecrets:
......
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