简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM