How a SpringBoot service in Kubernetes cluster knows about counter services address changing?

4/16/2020

I have bunch of applications in a Kubernetes cluster, they connect to each other, like SpringBoot application connect to RabbitMQ. They all are in containers.

Usually standalone SpringBoot app reads configs from application.yaml/bootstrap.yaml but AFAIK in case of Kubernetes cluster it reads it from ConfigMap, and address of counter services should be stored there ( is it?)

So the question is: in case of RabbitMQ pod's redeploy ( e.g. fail and restart) how SpringBoot is triggered to reread new configs? Who triggers it? When?

-- J.J. Beam
configmap
kubernetes
spring-boot

1 Answer

4/16/2020

Spring cloud kubernetes has proertysource reload feature and is able to trigger an application reload when a related ConfigMap or Secret changes. So if rabbitmq endpoint changes you can update the configMap and application will reload automatically and pick up the new config. But in a real production scenario you will have a stable endpoint for rabbitmq exposed via kubernetes services. Even though pod IPs may change the service IP or DNS will remain same.

The rabbitmq should be deployed as StatefulSet providing table, unique network identifiers.

-- Arghya Sadhu
Source: StackOverflow