How to restart multiple spring boot app instances of a kubernetes service

12/18/2018

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.

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

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?

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.

Is there a standard way in springboot-on-k8s I can call each service instance ignoring the LB?

-- Bilal Issa
java
kubernetes
spring-boot

2 Answers

12/18/2018

I'm not aware of a standard pattern for doing this.

Each of your application pods that match the selector for your service will be registered as an endpoint for that service. If you run kubectl get endpoints you should see all the internal clusterIPs for the pods backing your service.

You could create some logic to call that /refresh endpoint for every service endpoint.

-- switchboard.op
Source: StackOverflow

12/25/2018

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.

https://www.google.com/url?sa=t&source=web&rct=j&url=https://medium.com/platformer-blog/enable-rolling-updates-in-kubernetes-with-zero-downtime-31d7ec388c81&ved=2ahUKEwjIqtbW_bvfAhUKRY8KHas6DEkQjjgwAnoECAkQAQ&usg=AOvVaw3HjD4CUoG4ma3HWxquaYjp&cshid=1545776336374

-- Bal Chua
Source: StackOverflow