【问题标题】:Openshift readiness and liveness probe never failing even with incorrect http url即使 http url 不正确,Openshift 就绪和活跃度探测也永远不会失败
【发布时间】:2021-04-19 18:47:37
【问题描述】:

我正在 OpenShift Pod 中运行 Spring Boot 2.0.0 应用程序。为了执行就绪和活跃度探测,我依赖于 spring boot 执行器健康检查。我的应用程序属性文件具有以下属性:

server.address=127.0.0.1
management.server.address=0.0.0.0
server.port=8080
management.server.port=8081
management.endpoints.enabled-by-default=false
management.endpoint.info.enabled=true
management.endpoint.health.enabled=true
management.endpoints.web.exposure.include=health,info
management.endpoint.health.show-details=always
management.security.enabled=false

按照readiness和liveness probe的相关配置。

livenessProbe:
    failureThreshold: 3
    httpGet:
      path: /mmcc
      port: 8081
      scheme: HTTP
    initialDelaySeconds: 35
    periodSeconds: 10
    successThreshold: 1
    timeoutSeconds: 15


readinessProbe:
    failureThreshold: 3
    httpGet:
      path: /jjkjk
      port: 8081
      scheme: HTTP
    initialDelaySeconds: 30
    periodSeconds: 10
    successThreshold: 1
    timeoutSeconds: 15

我的期望是,我的准备和活跃度探测应该会因这些随机 url 而失败,但它们会成功。 不知道我在这里缺少什么。请帮忙。

【问题讨论】:

  • 当返回 HTTP 错误代码(通常是 HTTP 5XX / HTTP 4XX)时,探测将失败。您可以将容器内curl -vvv localhost:8081/jjkjk 的输出添加到您的问题中吗?

标签: kubernetes openshift spring-boot-actuator readinessprobe livenessprobe


【解决方案1】:

Simon 的回答给了我一个起点,我寻找 curl -vvv localhost:8081/jjkjk 输出。 该 URL 将我重定向到登录 url,所以我认为这是因为我的类路径中有弹簧安全性。 所以我在我的属性文件中添加了:

management.endpoints.web.exposure.include=health,info

并添加

@Configuration
public class ActuatorSecurity extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests()
            .anyRequest().permitAll()
    }

}

这通过启用无需凭据访问 url 解决了我的问题。

【讨论】:

    猜你喜欢
    • 2021-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-28
    • 1970-01-01
    • 2021-11-04
    • 1970-01-01
    相关资源
    最近更新 更多