问题
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 healthspring.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 servicespring.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
totrue
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