问题描述
我在3节点kubernetes集群上进行了Spring Boot服务A的负载均衡部署.
I have a load balanced deployment of spring boot service A, say on a 3 node kubernetes cluster.
我还需要启用快速配置管理,而无需重建和部署完整的重新烘焙映像.
I also have a requirement to enable quick configuration management without needing to rebuild+deploy a full blown rebaked image.
为此,我整理了一个弹簧启动配置服务器,并在服务A上实现了Actuator重新启动,当在本地单实例部署上调用其/restart端点时,它会刷新并加载从config-中获取的属性.服务器.
For that I put together a spring boot config-server, as well as implemented the Actuator restart on service A which when calling its /restart endpoint on a local single instance deployment it refreshes and loads with the properties fetched from the config-server.
到目前为止很好,但是...
So far so good, but...
当将服务A部署到具有3、30或300个服务A实例的大规模k8s部署中时,如何实现上述目标?
How can the above be achieved when service A is deployed on a larger scale k8s deployment with 3, 30 or 300 instances of service A?
调用/refresh终结点必须由负载均衡器处理,就像集群上的任何其他REST调用一样,这意味着它被路由到服务实例之一.
Calling /refresh endpoint must be handled by the load balancer as any other REST call on the cluster, meaning it is routed to one of the service instances.
在springboot-on-k8s中有一种标准方法可以让每个服务实例忽略LB吗?
Is there a standard way in springboot-on-k8s I can call each service instance ignoring the LB?
推荐答案
我们并没有真正使用执行器的重启,而是使用了rollingUpdate策略进行部署.当我们想重启"豆荚时,我们发布一个kubectl补丁.
We don't really use the actuator's restart, instead what we do is, utilize the rollingUpdate strategy of deployment. When we want to "restart" the pods, we issue a kubectl patch.
kubectl patch deployment web -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"`date +'%s'`\"}}}}}"
有关升级策略的良好文档.
A good documentation of the upgrade strategy.
这篇关于如何重启Kubernetes服务的多个Spring Boot应用程序实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!