<p>I'm curious on how the <code>@Value</code> works internally on Spring so that it can actually read value from <code>ConfigMap</code> of Kubernetes Cluster.</p>
<p>I know that:</p>
<ul>
<li><code>@Value(&quot;${my.nested.variable}&quot;)</code> were used to access variables
declared on <code>application.properties</code> or in OS' environment variable
(higher priority).</li>
<li>When creating new ConfigMap on kubernetes (for Spring project), you usually do <code>kubectl create configmap my-config-name --from-file=application.properties</code>, and it will magically connect those <code>ConfigMap</code> values with respective <code>@Value()</code> on Spring, of course we have to select <code>my-config-name</code> on deployment YAML file.</li>
</ul>
<p>Notice above that we <strong>didnt expose/map</strong> those configmap to container's environment variable, already checked the inside container with <code>printenv</code> , <strong>can't find it</strong>.
However, Spring were still able to retrieve those value from ConfigMap to be used in java program.</p>
<p>How is it possible? anyone know how Spring's <code>@Value</code> works or how the <code>ConfigMap</code> actually works internally so those two can <strong>magically</strong> connected?</p>
<p>Thank You.</p>

xcode
<p>This is a community wiki answer. Feel free to expand it.</p>
<p>As already mentioned by David Maze in the comments, <a href="https://spring.io/projects/spring-cloud-kubernetes" rel="nofollow noreferrer">Spring Cloud Kubernetes</a> is reading <a href="https://docs.spring.io/spring-cloud-kubernetes/docs/current/reference/html/#kubernetes-propertysource-implementations" rel="nofollow noreferrer">ConfigMaps</a> by using <a href="https://kubernetes.io/docs/reference/using-api/" rel="nofollow noreferrer">Kubernetes API</a>. The mechanisms behind it are described in the linked docs.</p>
