在Kubernetes上使用Spring Boot Admin监视副本 [英] Monitoring replicas with Spring Boot Admin on Kubernetes

查看:645
本文介绍了在Kubernetes上使用Spring Boot Admin监视副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Kubernetes上设置了一个Spring Boot Admin Client,并最多扩展了3个副本,但是当我尝试检查实例时,Admin Server仅显示一个

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

推荐答案

为了使SBA(Spring Boot管理员)了解您的服务的三个实例是不同的,您需要确保每个实例都使用其服务在SBA中注册内部IP地址".

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".

这样做可以让SBA独立地查询每个实例的运行状况,并导致spring为每个吊舱创建唯一的实例ID.

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

请注意,使用k8s服务名称进行注册会导致SBA的运行状况查询在该服务的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.

为此,请在您的application.yml中添加以下内容:

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

具有:

  • K8S_POD_IP是一个环境变量,其Pod的IP地址必须可以从SBA访问-这是SBA将用来查询服务实例的运行状况的地址
  • spring.boot.admin.client.url是单击服务实例时SBA的UI将使用的URL-此URL应指向k8s的服务
  • spring.boot.admin.client.management-base-url-SBA用来监视每个服务的运行状况,对于每个实例都应该是唯一的,并且可以从SBA进行访问
  • 如果每次发布更新或缩减服务时都没有将auto-deregistration设置为true,则会收到不正常实例的通知-使用此设置,实例将在关机时从SBA降级./li>
  • 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.

这篇关于在Kubernetes上使用Spring Boot Admin监视副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆