<p>I have a spring boot web app which simply prints a property that is passed in a Kubernetes' ConfigMap.</p>

<p>This is my main class:</p>

<pre><code>@SpringBootApplication
@EnableDiscoveryClient
@RestController
public class DemoApplication {

    private MyConfig config;
    private DiscoveryClient discoveryClient;

    @Autowired
    public DemoApplication(MyConfig config, DiscoveryClient discoveryClient) {
        this.config = config;
        this.discoveryClient = discoveryClient;
    }

    @RequestMapping("/")
    public String info() {
        return config.getMessage();
    }

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @RequestMapping("/services")
    public String services() {
        StringBuilder b = new StringBuilder();
        discoveryClient.getServices().forEach((s) -&gt; b.append(s).append(" , "));
        return b.toString();
    }

}
</code></pre>

<p>and the <code>MyConfig</code> class is:</p>

<pre><code>@Configuration
@ConfigurationProperties(prefix = "bean")
public class MyConfig {

    private String message = "a message that can be changed live";

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
</code></pre>

<p>Basically, by invoking root resource I always get:</p>

<blockquote>
  <p>a message that can be changed live</p>
</blockquote>

<p>And invoking /services I actually get a list of Kubernetes services.</p>

<p>I'm creating the ConfigMap with <code>kubectl create -f configmap-demo.yml</code> being the content:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: demo
data:
    bean.message: This is an info from k8
</code></pre>

<p>And the deployment with <code>kubecetl create -f deploy-demo.yml</code> and the content is:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo
  labels:
    app: demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demo
  template:
    metadata:
      labels:
        app: demo
    spec:
      # this service account was created according to
      # https://kubernetes.io/docs/reference/access-authn-authz/rbac/#service-account-permissions
      # point 5 - Grant super-user access to all service accounts cluster-wide (strongly discouraged)
      serviceAccountName: i18n-spring-k8
      containers:
      - name: demo
        image: aribeiro/sck-demo
        imagePullPolicy: Never
        env:
        - name: JAVA_OPTS
          value:
        ports:
        - containerPort: 8080
      volumes:
      - name: demo
        configMap:
          name: demo
</code></pre>

<p>The problem is that when accessing the root resource <code>/</code> I always get the default hardcoded value and never what is defined in Kubernetes' ConfigMap.</p>

<p>Example project also with yaml files and Docker file available at <a href="https://drive.google.com/open?id=107IcwnYIbVpmwVgdgi8Dhx4nHEFAVxV8" rel="nofollow noreferrer">https://drive.google.com/open?id=107IcwnYIbVpmwVgdgi8Dhx4nHEFAVxV8</a> .</p>

<p>Also checked the startup DEBUG logs and I don't see any error or clue why it should not work.</p>

<p>The <a href="https://github.com/spring-cloud/spring-cloud-kubernetes/blob/master/README.adoc#kubernetes-propertysource-implementations" rel="noreferrer">Spring Cloud Kubernetes documentation</a> is incomplete. It lacks the instruction to include this dependency to enable loading application properties from ConfigMap's:</p>

<pre><code>&lt;dependency&gt;
  &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
  &lt;artifactId&gt;spring-cloud-starter-kubernetes-config&lt;/artifactId&gt;
&lt;/dependency&gt;
</code></pre>
