Commit d604ed96 authored by 黎博's avatar 黎博

java服务健康检查调整

parent 382faf5d
......@@ -708,42 +708,40 @@ public class K8sService {
container.setResources(resourceRequirements);
// keystone、sc-task 健康检查单独处理
if (StringUtils.equals(namespace, "gyl2") || StringUtils.equals(namespace, "vcc2")) {
if (StringUtils.equals(serviceName, "keystone") || StringUtils.equals(serviceName, "sc-task") || StringUtils.equals(serviceName, "sc-auth") || StringUtils.equals(serviceName, "price-tracker")) {
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 ProbeBuilder()
.withHttpGet(httpGetAction)
.withInitialDelaySeconds(15)
.withPeriodSeconds(5)
.withTimeoutSeconds(5)
.withSuccessThreshold(1)
.withFailureThreshold(3)
.build();
container.setReadinessProbe(readinessProbe);
}
// keystone、sc-task、sc-auth、price-tracker 健康检查单独处理
if (StringUtils.equals(serviceName, "keystone") || StringUtils.equals(serviceName, "sc-task") || StringUtils.equals(serviceName, "sc-auth") || StringUtils.equals(serviceName, "price-tracker")) {
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 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();
......
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