【问题标题】:Healthcheck of SpringBoot service in Gitlab CI/CD pipelineGitlab CI/CD 管道中 SpringBoot 服务的健康检查
【发布时间】:2020-11-16 09:12:02
【问题描述】:

我有一个 Gitlab CI/CD 管道:

  • 构建 Spring Boot 应用
  • 将其打包到 Docker 映像中
  • 使用docker run ...部署镜像

我希望能够在部署后验证服务。我希望管道通知我有关失败的信息。我想我需要在管道中增加一个 healthcheck 步骤来验证服务。

此任务是否有任何最佳实践?有没有现成的解决方案?

【问题讨论】:

    标签: spring-boot gitlab-ci health-check spring-actuator gitlab-pipelines


    【解决方案1】:

    可以使用弹簧执行器 + curl + grep 来实现检查。

    管道:

    check-spring-actuator-health:
      image: curlimages/curl
      stage: Health Ckeck
      script:
    # exit with error if actuator/health doesn't return 'UP'
        - curl $ACTUATOR_HEALTH_URL | grep "{\"status\":\"UP\"}" || ( echo Helth Check Failed Actuator=$ACTUATOR_HEALTH_URL && exit 2; )
    

    如果执行器/健康 URL 不可用或返回除 {"status":"UP"} 以外的任何内容,此步骤将失败

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-18
      • 1970-01-01
      • 2019-06-05
      • 2021-12-21
      • 2021-11-30
      • 2021-04-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多