springcloud+nacos 因为设置了context-path导致服务健康检查不生效的一个问题

原因

服务设置了context-path, 所以健康检查的路径也要做适配

server:
  address: 0.0.0.0
  port: 8083
  servlet:
    # 这里设置了context-path
    context-path: /settlement/v1

spring:
  application:
    name: settlement
  cloud:
    nacos:
      config:
        server-addr: nacos-headless.default.svc.cluster.local:8848
      discovery:
        server-addr: nacos-headless.default.svc.cluster.local:8848
        metadata:
          management:
            # 这里要适配下健康检查的endpoint
            context-path: '${server.servlet.context-path}/actuator'

management:
  endpoints:
    web:
      exposure:
        # actuator暴露所有endpoint
        include: "*"

一些Nacos Open Api

# 注销实例
curl -X DELETE 127.0.0.1:8848/nacos/v1/ns/instance?serviceName=service_name\&ip=127.0.0.1\&port=8888
# 查询服务的所有实例
curl -X GET 127.0.0.1:8848/nacos/v1/ns/instance/list?serviceName=service_name
# 查询具体实例
curl -X GET '127.0.0.1:8848/nacos/v1/ns/instance?serviceName=service_name&ip=127.0.0.1&port=8888&cluster=DEFAULT'
# 更新实例的健康状态
curl -X PUT 'http://127.0.0.1:8848/nacos/v1/ns/health/instance?port=8888&healthy=false&ip=127.0.0.1&serviceName=service_name'

你可能感兴趣的:(java)