-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to detect that a configmap is present #1682
Comments
Can I ask why and what you are trying to accomplish by knowing this? |
Sure. |
One approach I can think of is to have a Bean which takes in all |
Thanks for this possible solution. With With 'spring.cloud.bootstrap.enabled: true', no I prefer the 1st possibility, but the issue is if I add |
You are going to have to provide more information than "the app doesn't start" for us to help |
Indeed, sorry.
|
Do you have any idea where this is coming from |
Here is a sample repository https://github.com/c4rth/spring-k8s The 'configDataConfigMapConfigProperties' is defined in method registerProperties of KubernetesConfigDataLocationResolver |
OK looking at your sample gave me more clues. Why are you specifying |
So |
I have a spring boot 3 application deployed in Kubernetes and also a configmap
The spring app uses :
implementation("org.springframework.cloud:spring-cloud-starter")
implementation("org.springframework.cloud:spring-cloud-starter-kubernetes-fabric8-all")
In Kubernetes, the app has an environment variable
SPRING_CLOUD_BOOTSTRAP_ENABLED
to true.I would like to verify that a configmap linked to the application is available and has been loaded.
rem: I don't known which values will be defined in it, I cannot check one value, I just want check its existence.
What I tried
I tried to detect this in an
org.springframework.boot.env.EnvironmentPostProcessor
(maybe not the best place) loaded with spring.factoriesDetect that the application is running in Kubernetes is easily done with
CloudPlatform.KUBERNETES.isActive(environment)
But I don't find a way to detect the configmap.
I tried in the EnvironmentPostProcessor to check the different property sources of the environment, I found one named 'KUBERNETES_NAMESPACE_PROPERTY_SOURCE' but with or without a configmap, it exists.
And my EnvironmentPostProcessor is executed before my app starts and
I tried combinations:
with and without
org.springframework.cloud:spring-cloud-starter-bootstrap
with and without
SPRING_CLOUD_BOOTSTRAP_ENABLED
Here is the code of my EnvironmentPostProcessor
An other strange thing: the TestEnvironmentPostProcessor runs before the app starts and after.
In both case the properties defined in configmap are unknow.
When my app has started, the values are known, here is the log
The text was updated successfully, but these errors were encountered: