0

I am having Kubernetes Config map in spring boot project and My application should dynamically get the values from config map if any values changes in config map so for that I have used spring cloud kubernetes config like below in bootstarp.yml file

spring:
  profiles: dev, preprod
  cloud:
    kubernetes:
      reload:
        enabled: true
      config:
        enabled: true
        sources:
          - namespace: ${kubernetesnamespace}
            name: ${configmapname}

After deploying the application , If I go and change the config map value I am able to get in application without restart which is expected but If I change the config map value after 1 hour of deployment this new value of config map is not reflecting in application but same I f do after 5 mins of deployment it is working. So what could be the reason.

2 Answers 2

0

what could be the reason

My first suspect would be the application itself. That probably "watches" for the ConfigMap (opens a long-living connection, subscribing for changes on that object). Eventually, those connections may close, which is normal/expected (container restart, etcd leader changes, SDN issues, ...).

I would make sure my application properly acknowledges those and re-connects to the API.

Sign up to request clarification or add additional context in comments.

Comments

0

For reload to work, the classes candidate for reloading are needed to be annotated with @RefreshScope.

Please see documentation reference: https://docs.spring.io/spring-cloud-kubernetes/docs/current/reference/html/#propertysource-reload

Notice that default reload strategy is "refresh" and whole context is not reloaded unless specified. I hope that helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.