1

I'm trying to adapt my Spring boot application to k8s environment and want to use ConfigMaps as property sources. I faced that if I'm using

      kubernetes:
        config:
          sources:
            - name: application-config

for application with name appName then any other ConfigMaps with Spring cloud kubernetes convention names like appName-kubernetes or appName-dev is silently ignored. Looks like listed sources in config.sources overrides and disables usage of any other PropertySources from ConfigMaps.
I'm forced to use specific name for ConfigMap ('application-config' in sample above).

So question is - how (if) can I specify both config.sources and simultaneously have ConfigMaps with names appName-* picked up correctly?

  • I wrote or refactored the vast majority of that code in spring-cloud-kubernetes, but I am really confused on what you are trying to ask about. It seems from your answer that you have a config map - `A` and an application name `B`, and you expect to have loaded `A-kubernetes`, `B-kubernetes`, `A` and `B`, that is 4 config maps (or more depending on how many profiles you have), right? – Eugene Oct 16 '21 at 16:50

1 Answers1

1

After some debugging through ConfigMapPropertySource achieved this by

    kubernetes:
      config:
        sources:
          - name: application-config
          - name: @project.artifactId@
        name: @project.artifactId@

Now it loads application-config, application-config-kubernetes, appName-kubernetes and other profile-specific ConfigMaps.

  • 1
    I think I understood what you are asking about here, and yes - this is how you would achieve it. Note that you do not need `kubernetes.config.name: @project.artifactId@`, as this acts as a "default" value when `kubernetes.config.sources[].name` is not present. – Eugene Oct 16 '21 at 16:52