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