Home > Net >  Spring boot pick up dynamic application.properties from kubernetes configmap
Spring boot pick up dynamic application.properties from kubernetes configmap

Time:03-08

We have springboot application running as a pod , it picks from application.properties from configmap. When we update configmap this change is not picked up springboot aplication , we need to restart the application to pick new property change. Can we do this without restarting the sringboot application pod to pick new properties.

CodePudding user response:

No, ideally you can not do it, you need to restart the POD if you are using the config map.

However, you can set the auto reloader which will do work for you, whenever configmap will get updated it will auto restart the PODs of deployment so you won't need to manually restart the PODs.

You can read more about it here Reloader : https://github.com/stakater/Reloader

Or else

you can export the variable with this command however it not permanent solution

kubectl exec -it <pod_name> export VARIABLENAME=<value>

CodePudding user response:

The problem you are facing is that spring boot config doesn't know when to do a refresh of the config.

You have two options

  1. If you want to refresh whenever the config changes use spring cloud k8s watcher link to project

2. Restart the pod whenever config changes. There are many controllers available to do

  • Related