How to load properties from kubernetes configMap based on activated spring profiles

11/4/2018

Using helm I am setting the SPRING_PROFILES_ACTIVE as a dev or prod based on the environment. But now I want to load properties from kubernetes configMap based on the activated profile.

Below is the sample configMap

apiVersion: v1
data:
  application-dev.properties: |-
    spring.profiles=dev
    host=hello-dev
  application-prod.properties: |-
    spring.profiles=prod
    host=hello-prod
  application.properties: |-
    host: hello-app
kind: ConfigMap

I am using io.fabric8 kubernetes dependency to use configMap in order to replace the spring cloud config server.

Output of sample API to fetch host property always gives the values as "hello-app" even though dev profile is activated.

Please suggest any method of solving the issue.

Thanks

-- ravi
fabric8
kubernetes
spring-boot
spring-cloud-config

0 Answers