ConfigMap with multiple yaml files and bootstrap.yaml one of them
See original GitHub issueDescribe the bug Hello, I’m trying to find out the way how to provide local development and also configure application for kubernetes. So for local development we are using something like this structure:
application/
├── config/
│ ├── application.yaml
│ ├── bootstrap.yaml
└── src/
└── main/
└── resources/
├── application.yaml
└── bootstrap.yaml
so in config/
folder we have configuration for our local development
in resources/
folder we have configuration with defaults which we don’t want to override
and in configmap I’d like to use something like this:
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ template "chart.fullname" . }}
data:
application-kubernetes.yaml: |-
...
bootstrap-kubernetes.yaml: |-
...
where I’d like to provide only the configs that I want to change for kubernetes.
However it looks like the bootstrap-kubernetes.yaml
file didn’t took effect.
Is such patter available or what whould be the best option to provide also configuration for boostrap.yaml
?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Is it possible to configure spring.cloud.config to use multiple ...
yaml file. For example, one configMap may contain the config server URI, and the second configMap may contain overrideSystemProperties property.
Read more >Best practices on Spring Cloud Kubernetes bootstrap ...
On purpose to externalise application's properties there are two most commons ways to implement this: k8s configmap; Spring Cloud Config ...
Read more >2. ConfigMap PropertySource - Spring Cloud
properties|yaml files. The Spring Cloud Kubernetes Config project makes Kubernetes `ConfigMap`s available during application bootstrapping and triggers hot ...
Read more >Using Kubernetes ConfigMaps to Manage Spring Application ...
In the Java and Spring ecosystems, there are multiple ways to pass the configuration data to the application, like providing command line ...
Read more >Chapter 7. Integrate Spring Boot with Kubernetes
properties file (or bootstrap.yaml file), set the spring.application.name property to match the name of the ConfigMap. Enable the view ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I could take a stab at this one, but imo, we need to establish some (documented) rules here.
here is my proposal:
yaml/yml/properties
- treat it as a “file”, we don’t care about its name. (this is the current behavior)<SPRING_APPLICATION_NAME>.yaml/yml/properties
(orapplication.yaml/yml/properties
ifSPRING_APPLICATION_NAME
is missing) + all their profile based ones. For example, let’s suppose thatspring.application.name=my-name
and active profiles =k8s
; a config like:This will result in three entries being read:
my-name.yaml
treated as a filemy-name-k8s.yaml
treated as a filemy-name-dev.yaml
ignored since there is no such profiledev
activesomeProp: someValue
plain propertyIf you agree, or have any other suggestions, do let me know; when I get a green light, I will implement this. thank you
This is kind of an interesting problem. The problem is here
https://github.com/spring-cloud/spring-cloud-kubernetes/blob/master/spring-cloud-kubernetes-config/src/main/java/org/springframework/cloud/kubernetes/config/ConfigMapPropertySource.java#L161
When there are multiple files defined in a single configmap they need to be named application.yaml application.yml or application.properties. Since you have
-kubernetes
appended and you also havebootstrap-kubernetes
we just make the file name the key and the content the value.If you hit
/actuator/env
I am sure you will see that in the output.I dont see a reason why the file name really matters in the case of using the API to read the ConfigMap and we wouldnt head down this path when reading from a path. I think the fix is really just to check that the file extension in the configmap is either yaml yml or properties.
The interesting problem has to do with profiles…I am not sure how to do that at the moment. You could have application-dev.yaml and application-production.yaml for example and right now that would all be combined into one property source.
The best workout I can offer at the moment would be to separate the files into different configmaps.