0

We would like to have multiple instances of the same application in the same Kubernetes namespace. We can do that by using the name suffix capability of kustomize, so that hostname "X" becomes "X-something-unique" and that works well.

Unfortunately, we need the Spring Boot application to know how to reach the name suffixed Postgres database, so we cannot just hardcode the hostname into the JDBC URL in application.yaml (which is passed in as a configuration map).

I am not deeply familiar with these things, so what is the recommended way to do this?

glv
  • 994
  • 1
  • 1
  • 15
Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • I would look at the spring-boot exernal config example, and in you're case from the kubernestes env setup you'd set the 'X-something-unique-name' as a system property from which the spring-boot app would read on it's startup. See https://docs.spring.io/spring-boot/docs/2.1.9.RELEASE/reference/html/boot-features-external-config.html#:~:text=Spring%20Boot%20lets%20you%20externalize,line%20arguments%20to%20externalize%20configuration. – emeraldjava Mar 14 '23 at 13:06
  • @emeraldjava Sounds like the right approach. How would you suggest I set the system property in the deployment? – Thorbjørn Ravn Andersen Mar 14 '23 at 14:47
  • I'm guessing something like this would work.... https://www.tutorialworks.com/spring-boot-kubernetes-override-properties/#attach-the-configmap-to-your-deployment – emeraldjava Mar 14 '23 at 15:46

0 Answers0