Commit f6120e2d authored by 黎博's avatar 黎博

健康检查逻辑新增keystone单独处理

parent f896c0a1
...@@ -576,7 +576,7 @@ public class K8sService { ...@@ -576,7 +576,7 @@ public class K8sService {
* @param dockerProject * @param dockerProject
* @return * @return
*/ */
public Deployment createJavaDeployment(ServiceCreateVo serviceCreateVo, DockerProject dockerProject) { public Deployment createJavaDeployment(ServiceCreateVo serviceCreateVo, DockerProject dockerProject) {
String namespace = serviceCreateVo.getNamespace(); String namespace = serviceCreateVo.getNamespace();
String serviceName = serviceCreateVo.getServiceName(); String serviceName = serviceCreateVo.getServiceName();
String mock = serviceCreateVo.getMock().toString(); String mock = serviceCreateVo.getMock().toString();
...@@ -679,42 +679,76 @@ public class K8sService { ...@@ -679,42 +679,76 @@ public class K8sService {
container.setResources(resourceRequirements); container.setResources(resourceRequirements);
// 需要做健康检查的不创建存活检查和就绪检查 // keystone 健康检查单独处理
List<String> noHealthCheckServiceList = Arrays.asList(noHealthCheckService.split(",")); if (StringUtils.equals(serviceName, "keystone")) {
if (!noHealthCheckServiceList.contains(serviceName)) { IntOrString httpPort = new IntOrStringBuilder().withIntVal(80).build();
ExecAction execAction = new ExecAction();
List<String> commandList = new ArrayList<>(); HTTPGetAction httpGetAction = new HTTPGetActionBuilder()
commandList.add("/home/quant_group/readyCheck.sh"); .withPath("/actuator/health/readiness")
execAction.setCommand(commandList); .withPort(httpPort)
// livenessProbe 存活检查,检查容器是否正常,不正常则重启实例 .build();
Probe livenessProbe = new Probe();
livenessProbe.setExec(execAction); Probe livenessProbe = new ProbeBuilder()
// 启动延时,容器延时启动健康检查的时间 .withHttpGet(httpGetAction)
livenessProbe.setInitialDelaySeconds(600); .withInitialDelaySeconds(600)
// 间隔时间,进行健康检查的时间间隔 .withPeriodSeconds(60)
livenessProbe.setPeriodSeconds(60); .withTimeoutSeconds(60)
// 响应超时,每次健康检查响应的最大超时时间 .withTimeoutSeconds(5)
livenessProbe.setTimeoutSeconds(5); .withSuccessThreshold(1)
// 健康阈值,表示后端容器从失败到成功的连续健康检查成功次数 .withFailureThreshold(5)
livenessProbe.setSuccessThreshold(1); .build();
// 不健康阈值
livenessProbe.setFailureThreshold(5);
container.setLivenessProbe(livenessProbe); container.setLivenessProbe(livenessProbe);
//readinessProbe 就绪检查,检查容器是否就绪,不就绪则停止转发流量到当前实例 //readinessProbe 就绪检查,检查容器是否就绪,不就绪则停止转发流量到当前实例
Probe readinessProbe = new Probe(); Probe readinessProbe = new ProbeBuilder()
readinessProbe.setExec(execAction); .withHttpGet(httpGetAction)
// 启动延时 .withInitialDelaySeconds(15)
readinessProbe.setInitialDelaySeconds(15); .withPeriodSeconds(5)
// 响应超时 .withTimeoutSeconds(5)
readinessProbe.setTimeoutSeconds(5); .withSuccessThreshold(1)
// 间隔时间 .withFailureThreshold(3)
readinessProbe.setPeriodSeconds(5); .build();
// 健康阈值
readinessProbe.setSuccessThreshold(1);
// 不健康阈值
readinessProbe.setFailureThreshold(3);
container.setReadinessProbe(readinessProbe); container.setReadinessProbe(readinessProbe);
} else {
// 需要做健康检查的不创建存活检查和就绪检查
List<String> noHealthCheckServiceList = Arrays.asList(noHealthCheckService.split(","));
if (!noHealthCheckServiceList.contains(serviceName)) {
ExecAction execAction = new ExecAction();
List<String> commandList = new ArrayList<>();
commandList.add("/home/quant_group/readyCheck.sh");
execAction.setCommand(commandList);
// livenessProbe 存活检查,检查容器是否正常,不正常则重启实例
Probe livenessProbe = new Probe();
livenessProbe.setExec(execAction);
// 启动延时,容器延时启动健康检查的时间
livenessProbe.setInitialDelaySeconds(600);
// 间隔时间,进行健康检查的时间间隔
livenessProbe.setPeriodSeconds(60);
// 响应超时,每次健康检查响应的最大超时时间
livenessProbe.setTimeoutSeconds(5);
// 健康阈值,表示后端容器从失败到成功的连续健康检查成功次数
livenessProbe.setSuccessThreshold(1);
// 不健康阈值
livenessProbe.setFailureThreshold(5);
container.setLivenessProbe(livenessProbe);
//readinessProbe 就绪检查,检查容器是否就绪,不就绪则停止转发流量到当前实例
Probe readinessProbe = new Probe();
readinessProbe.setExec(execAction);
// 启动延时
readinessProbe.setInitialDelaySeconds(15);
// 响应超时
readinessProbe.setTimeoutSeconds(5);
// 间隔时间
readinessProbe.setPeriodSeconds(5);
// 健康阈值
readinessProbe.setSuccessThreshold(1);
// 不健康阈值
readinessProbe.setFailureThreshold(3);
container.setReadinessProbe(readinessProbe);
}
} }
containerList.add(container); containerList.add(container);
......
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