Monitoring replicas with Spring Boot Admin on Kubernetes

会有一股神秘感。 提交于 2020-05-16 12:44:05

问题


I setted up a Spring Boot Admin Client on Kubernetes and scaled up to 3 replicas, but when I try to check the instances the Admin Server show just one


回答1:


In order for SBA (Spring Boot Admin) to understand that the three instances of your services are distinct, you need to make sure each is registered in SBA using its "internal IP address".

Doing so will let SBA query the health of each instance independently, and will result with spring creating unique instance-id for each pod.

Note that using the k8s service name for the registration will result with SBA's health queries being load-balanced across the service's pods.

To do this, add to your application.yml the following:

spring:
  boot.admin.client:
    url: http://<k8s-service-name-and-port>
    instance:
      name: <service-name>
      service-base-url: http://${K8S_POD_IP}:8080
      management-base-url: http://${K8S_POD_IP}:8081
    auto-deregistration: true

Having:

  • K8S_POD_IP is an environment-variable with the pod's IP address that must be accessible from SBA - this is the address that will be used by SBA to query for your service instance's health
  • spring.boot.admin.client.url is the URL that will be used by SBA's UI when you click on an instance of your service - this URL should point to k8s's service
  • spring.boot.admin.client.management-base-url - this is used by SBA to monitor every service's health, should be unique for every instance and should be accessible from SBA
  • If you don't set auto-deregistration to true whenever you roll out an update or scale down your service, you'll get notification of unhealthy instances - with this setting, instances will derigister from SBA when shutdown.



回答2:


you need set parameter in yml file:

eureka.instance.instance-id: ${spring.cloud.client.ip-address}:${server.port}


来源:https://stackoverflow.com/questions/56893105/monitoring-replicas-with-spring-boot-admin-on-kubernetes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!