Commit f6120e2d authored by 黎博's avatar 黎博

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

parent f896c0a1
......@@ -576,7 +576,7 @@ public class K8sService {
* @param dockerProject
* @return
*/
public Deployment createJavaDeployment(ServiceCreateVo serviceCreateVo, DockerProject dockerProject) {
public Deployment createJavaDeployment(ServiceCreateVo serviceCreateVo, DockerProject dockerProject) {
String namespace = serviceCreateVo.getNamespace();
String serviceName = serviceCreateVo.getServiceName();
String mock = serviceCreateVo.getMock().toString();
......@@ -679,42 +679,76 @@ public class K8sService {
container.setResources(resourceRequirements);
// 需要做健康检查的不创建存活检查和就绪检查
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);
// keystone 健康检查单独处理
if (StringUtils.equals(serviceName, "keystone")) {
IntOrString httpPort = new IntOrStringBuilder().withIntVal(80).build();
HTTPGetAction httpGetAction = new HTTPGetActionBuilder()
.withPath("/actuator/health/readiness")
.withPort(httpPort)
.build();
Probe livenessProbe = new ProbeBuilder()
.withHttpGet(httpGetAction)
.withInitialDelaySeconds(600)
.withPeriodSeconds(60)
.withTimeoutSeconds(60)
.withTimeoutSeconds(5)
.withSuccessThreshold(1)
.withFailureThreshold(5)
.build();
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);
Probe readinessProbe = new ProbeBuilder()
.withHttpGet(httpGetAction)
.withInitialDelaySeconds(15)
.withPeriodSeconds(5)
.withTimeoutSeconds(5)
.withSuccessThreshold(1)
.withFailureThreshold(3)
.build();
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);
......
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