Commit 19ac4619 authored by 智勇's avatar 智勇

存活检查

parent 327fce99
...@@ -183,28 +183,35 @@ const getPodStatus = (podInfo) => { ...@@ -183,28 +183,35 @@ const getPodStatus = (podInfo) => {
return 'Pending' return 'Pending'
} }
if (podInfo.status.conditions) { if (podInfo.status.conditions) {
if (podInfo.status.conditions[2].status === 'False') { for (const item of podInfo.status.conditions) {
if (item.type === 'Initialized' && item.status === 'False') {
return 'Initializing'
}
if (item.type === 'PodScheduled' && item.status === 'False') {
return 'PodScheduling' return 'PodScheduling'
} }
if (podInfo.status.conditions[0].status === 'False') { if (item.type === 'ContainersReady' && item.status === 'False') {
return 'Initializing' return 'ContainerCreating'
} }
if (podInfo.status.conditions[1].status === 'False') { if (item.type === 'Ready' && item.status === 'False') {
return 'Waiting' return 'Waiting'
} }
if (item.type === 'Ready' && item.status === 'True') {
return 'Normal'
}
}
} }
if (podInfo.metadata.deletionTimestamp) { if (podInfo.metadata.deletionTimestamp) {
return 'Terminating' return 'Terminating'
} }
return 'Normal'
} }
const formatPodInfo = (podInfo) => { const formatPodInfo = (podInfo) => {
// if (podInfo.metadata.name.indexOf('xyqb') !== -1) {
// console.log(1, JSON.stringify(podInfo), podInfo.metadata.labels['qcloud-app'])
// }
const podStatus = getPodStatus(podInfo) const podStatus = getPodStatus(podInfo)
// for debug
// if (podInfo.metadata.name.indexOf('xyqb-user2') !== -1) {
// console.log(1, podStatus, JSON.stringify(podInfo.status.conditions))
// }
const imageID = _.get(podInfo.status.containerStatuses, '[0].imageID', '') const imageID = _.get(podInfo.status.containerStatuses, '[0].imageID', '')
const image = _.get(podInfo.spec.containers, '[0].image', '') const image = _.get(podInfo.spec.containers, '[0].image', '')
......
...@@ -5,7 +5,14 @@ const config = require('kubernetes-client').config ...@@ -5,7 +5,14 @@ const config = require('kubernetes-client').config
module.exports = function client() { module.exports = function client() {
const client = {} const client = {}
return async function (ctx, next) { return async function (ctx, next) {
const exclude = ['/service/listEnvVarsNew', '/service/listEnvVars', '/cluster'] const exclude = [
'/service/listEnvVarsNew',
'/service/listEnvVars',
'/cluster',
'/repository',
'/repository/getTags',
'/repository/getNamespaceInfo',
]
if (exclude.includes(ctx.path)) { if (exclude.includes(ctx.path)) {
await next() await next()
} else { } else {
......
...@@ -84,7 +84,7 @@ spec: ...@@ -84,7 +84,7 @@ spec:
initialDelaySeconds: 30 initialDelaySeconds: 30
timeoutSeconds: 2 timeoutSeconds: 2
# 默认值10 # 默认值10
periodSeconds: 10 periodSeconds: 5
volumes: volumes:
- name: filelog - name: filelog
hostPath: hostPath:
......
...@@ -51,13 +51,17 @@ spec: ...@@ -51,13 +51,17 @@ spec:
value: qa value: qa
- name: MONGO_INITDB_ROOT_PASSWORD - name: MONGO_INITDB_ROOT_PASSWORD
value: qatest value: qatest
livenessProbe:
exec:
command: ["mongo", "-uqa", "-pqatest","admin"]
initialDelaySeconds: 100
successThreshold: 1
readinessProbe: readinessProbe:
exec: exec:
command: ["mongo", "-uqa", "-pqatest","admin"] command: ["mongo", "-uqa", "-pqatest","admin"]
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 2 periodSeconds: 5
timeoutSeconds: 1 timeoutSeconds: 1
failureThreshold: 40
volumeMounts: volumeMounts:
- mountPath: "/var/lib/mongo" - mountPath: "/var/lib/mongo"
name: {{serviceName}} name: {{serviceName}}
......
...@@ -72,13 +72,17 @@ spec: ...@@ -72,13 +72,17 @@ spec:
value: Quantgroup2017 value: Quantgroup2017
- name: MYSQL_USER - name: MYSQL_USER
value: qa value: qa
livenessProbe:
exec:
command: ["mysql", "-uqa", "-pqatest", "-e", "SELECT 1"]
initialDelaySeconds: 100
successThreshold: 1
readinessProbe: readinessProbe:
exec: exec:
command: ["mysql", "-uqa", "-pqatest", "-e", "SELECT 1"] command: ["mysql", "-uqa", "-pqatest", "-e", "SELECT 1"]
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 2 periodSeconds: 5
timeoutSeconds: 1 timeoutSeconds: 1
failureThreshold: 40
volumeMounts: volumeMounts:
- mountPath: "/var/lib/mysql" - mountPath: "/var/lib/mysql"
name: {{serviceName}} name: {{serviceName}}
......
...@@ -53,6 +53,12 @@ spec: ...@@ -53,6 +53,12 @@ spec:
value: qa value: qa
- name: RABBITMQ_DEFAULT_PASS - name: RABBITMQ_DEFAULT_PASS
value: qatest value: qatest
livenessProbe:
exec:
command:
- /opt/readyCheck.sh
initialDelaySeconds: 100
successThreshold: 1
readinessProbe: readinessProbe:
exec: exec:
command: command:
...@@ -61,12 +67,10 @@ spec: ...@@ -61,12 +67,10 @@ spec:
timeoutSeconds: 2 timeoutSeconds: 2
periodSeconds: 5 periodSeconds: 5
successThreshold: 1 successThreshold: 1
failureThreshold: 40
# 数据持久化 # 数据持久化
volumeMounts: volumeMounts:
- name: {{serviceName}} - name: {{serviceName}}
mountPath: "/var/lib/rabbitmq" mountPath: "/var/lib/rabbitmq"
volumes: volumes:
- name: {{serviceName}} - name: {{serviceName}}
persistentVolumeClaim: persistentVolumeClaim:
......
...@@ -32,13 +32,17 @@ spec: ...@@ -32,13 +32,17 @@ spec:
limits: limits:
cpu: {{resources.cpu.limit}}m cpu: {{resources.cpu.limit}}m
memory: {{resources.memory.limit}}Mi memory: {{resources.memory.limit}}Mi
livenessProbe:
exec:
command: ["redis-cli", "-p", "6379","info"]
initialDelaySeconds: 100
successThreshold: 1
readinessProbe: readinessProbe:
exec: exec:
command: ["redis-cli", "-p", "6379","info"] command: ["redis-cli", "-p", "6379","info"]
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1 timeoutSeconds: 1
failureThreshold: 40 periodSeconds: 5
- image: ccr.ccs.tencentyun.com/{{image}} - image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: Always imagePullPolicy: Always
name: {{serviceName}}-6380 name: {{serviceName}}-6380
...@@ -50,13 +54,17 @@ spec: ...@@ -50,13 +54,17 @@ spec:
limits: limits:
cpu: {{resources.cpu.limit}}m cpu: {{resources.cpu.limit}}m
memory: 200Mi memory: 200Mi
livenessProbe:
exec:
command: ["redis-cli", "-p", "6380","info"]
initialDelaySeconds: 100
successThreshold: 1
readinessProbe: readinessProbe:
exec: exec:
command: ["redis-cli", "-p", "6380","info"] command: ["redis-cli", "-p", "6380","info"]
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1 timeoutSeconds: 1
failureThreshold: 40 periodSeconds: 5
- image: ccr.ccs.tencentyun.com/{{image}} - image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: Always imagePullPolicy: Always
name: {{serviceName}}-6381 name: {{serviceName}}-6381
...@@ -68,13 +76,17 @@ spec: ...@@ -68,13 +76,17 @@ spec:
limits: limits:
cpu: {{resources.cpu.limit}}m cpu: {{resources.cpu.limit}}m
memory: {{resources.memory.limit}}Mi memory: {{resources.memory.limit}}Mi
livenessProbe:
exec:
command: ["redis-cli", "-p", "6381","info"]
initialDelaySeconds: 100
successThreshold: 1
readinessProbe: readinessProbe:
exec: exec:
command: ["redis-cli", "-p", "6381","info"] command: ["redis-cli", "-p", "6381","info"]
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1 timeoutSeconds: 1
failureThreshold: 40 periodSeconds: 5
- image: ccr.ccs.tencentyun.com/{{image}} - image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: Always imagePullPolicy: Always
name: {{serviceName}}-6382 name: {{serviceName}}-6382
...@@ -86,13 +98,17 @@ spec: ...@@ -86,13 +98,17 @@ spec:
limits: limits:
cpu: {{resources.cpu.limit}}m cpu: {{resources.cpu.limit}}m
memory: {{resources.memory.limit}}Mi memory: {{resources.memory.limit}}Mi
livenessProbe:
exec:
command: ["redis-cli", "-p", "6382","info"]
initialDelaySeconds: 100
successThreshold: 1
readinessProbe: readinessProbe:
exec: exec:
command: ["redis-cli", "-p", "6382","info"] command: ["redis-cli", "-p", "6382","info"]
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1 timeoutSeconds: 1
failureThreshold: 40 periodSeconds: 5
- image: ccr.ccs.tencentyun.com/{{image}} - image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: Always imagePullPolicy: Always
name: {{serviceName}}-6383 name: {{serviceName}}-6383
...@@ -104,13 +120,17 @@ spec: ...@@ -104,13 +120,17 @@ spec:
limits: limits:
cpu: {{resources.cpu.limit}}m cpu: {{resources.cpu.limit}}m
memory: {{resources.memory.limit}}Mi memory: {{resources.memory.limit}}Mi
livenessProbe:
exec:
command: ["redis-cli", "-p", "6383","info"]
initialDelaySeconds: 100
successThreshold: 1
readinessProbe: readinessProbe:
exec: exec:
command: ["redis-cli", "-p", "6383","info"] command: ["redis-cli", "-p", "6383","info"]
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1 timeoutSeconds: 1
failureThreshold: 40 periodSeconds: 5
dnsPolicy: ClusterFirst dnsPolicy: ClusterFirst
imagePullSecrets: imagePullSecrets:
- name: qcloudregistrykey - name: qcloudregistrykey
......
...@@ -63,15 +63,20 @@ spec: ...@@ -63,15 +63,20 @@ spec:
limits: limits:
cpu: {{resources.cpu.limit}}m cpu: {{resources.cpu.limit}}m
memory: {{resources.memory.limit}}Mi memory: {{resources.memory.limit}}Mi
livenessProbe:
exec:
command:
- /home/quant_group/readyCheck.sh
initialDelaySeconds: 100
successThreshold: 1
readinessProbe: readinessProbe:
exec: exec:
command: command:
- /home/quant_group/readyCheck.sh - /home/quant_group/readyCheck.sh
initialDelaySeconds: 2 initialDelaySeconds: 2
timeoutSeconds: 2 timeoutSeconds: 1
periodSeconds: 3 periodSeconds: 5
successThreshold: 1 successThreshold: 1
failureThreshold: 40
volumes: volumes:
- name: filelog - name: filelog
hostPath: hostPath:
......
...@@ -35,8 +35,6 @@ spec: ...@@ -35,8 +35,6 @@ spec:
qcloud-app: {{serviceName}} qcloud-app: {{serviceName}}
type: base type: base
spec: spec:
nodeSelector:
zone: "3"
containers: containers:
- image: ccr.ccs.tencentyun.com/{{image}} - image: ccr.ccs.tencentyun.com/{{image}}
imagePullPolicy: Always imagePullPolicy: Always
...@@ -48,14 +46,21 @@ spec: ...@@ -48,14 +46,21 @@ spec:
limits: limits:
cpu: {{resources.cpu.limit}}m cpu: {{resources.cpu.limit}}m
memory: {{resources.memory.limit}}Mi memory: {{resources.memory.limit}}Mi
livenessProbe:
exec:
command:
- /zookeeper-3.4.13/readyCheck.sh
initialDelaySeconds: 100
successThreshold: 1
# 默认值3
failureThreshold: 3
readinessProbe: readinessProbe:
exec: exec:
command: command:
- /zookeeper-3.4.13/readyCheck.sh - /zookeeper-3.4.13/readyCheck.sh
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1 timeoutSeconds: 1
failureThreshold: 40 periodSeconds: 5
volumeMounts: volumeMounts:
- mountPath: "/var/lib/zookeeper" - mountPath: "/var/lib/zookeeper"
name: {{serviceName}} name: {{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