spring-cloud-kubernetes icon indicating copy to clipboard operation
spring-cloud-kubernetes copied to clipboard

Kubernetes PropertySource order

Open asarkar opened this issue 8 years ago • 4 comments

What is the order of Kubernetes PropertySource with respect to the application's application.yml/bootstrap.yml files and config service? This should be documented in the README.

asarkar avatar Jan 07 '17 22:01 asarkar

I tried to find something in the spring boot documentation about custom property source order but couldn't find something. So here's what I remember from my own experience:

A custom property source, gets configured by bootstrap.yml and overrides values defined in application.yml. But I may not remember correctly.

@spencergibb: do u have a link to a doc that clarifies that? or do you remember something different?

iocanel avatar Jan 16 '17 17:01 iocanel

@spencergibb Bootstrap is loaded first and before application.properties/yaml - http://stackoverflow.com/questions/32997352/what-is-the-diference-between-putting-a-property-on-application-yml-or-bootstrap

cmoulliard avatar Mar 24 '17 16:03 cmoulliard

Could you please say on which level in respect to boot config order spring-cloud-kubernetes configmap kicks in?
We have issues trying to run app locally and having configmap taking precedence over everything, even command line args.
Probably related to this @Order annotation

golonzovsky avatar Nov 23 '17 08:11 golonzovsky

I did a quick test and it seems ConfigMapPropertySourceLocator takes priority over the dev tools as well, so I don't see a way to override values defined in the configmap during local development. I think this is an oversight, please correct me if I missed anything.

Given build.gradle

buildscript {
    ext {
        springBootVersion = '1.5.7.RELEASE'
    }
    repositories {
        mavenCentral()
        maven { url 'http://repo.spring.io/plugins-release' }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'/**/

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile('org.springframework.cloud:spring-cloud-kubernetes-config:0.2.0.RELEASE')
    runtime("org.springframework.boot:spring-boot-devtools")
    testCompile("org.springframework.boot:spring-boot-starter-test")
    testCompile("junit:junit:4.12")
}

and a simple com.test.App (spring.application.name=myapp)

@SpringBootApplication
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class);
    }
}

values defined in myapp configmap are taken over values defined in ~/.spring-boot-devtools.properties

ThanksForAllTheFish avatar Nov 27 '17 11:11 ThanksForAllTheFish