spring cloud config custom path - spring-cloud

git structure
/--|
|--/tenant-name1|
- tenant-name1.properties
|
|--/tenant-name2|
- tenant-name2.properties
i using props from single app but with multiple tenants. Tenants can be applied to project in runtime. All tenants properties in their own folder.
How i can configure path for get properties for tenantX?
tried different variants like
localhost:8888/tenantX/tenantX.properties
my spring cloud application.yaml
server.port: 8888
spring:
profiles:
active: git
cloud.config:
server:
git:
uri: https://gitlab.some.path.git
search-paths: '{application}'
username: dummy
password: dummy
default-label: release-candidate

just adding property
spring.cloud.config.server.native.searchLocations: {application}
and for application= tenantA it will be search in /tenantA/* folder
native using due underlying git cloned into local (into some /tmp/ fodler) and searching file via native (aka FileSystem repository)

Related

Config server with Vault backend - fetch secrets from multiple paths

We are using config server with Vault backend to fetch application secrets.
Config server project is using spring-vault-core dependency and spring-vault-dependencies dependency management for Vault.
Vault related config in application yml file is as follows:
spring:
cloud:
config:
server:
vault:
order: 0
uri: <complete URI>
connection-timeout: 5000
read-timeout: 15000
kvVersion: 2
backend: secret
defaultKey: config
This works fine and fetches me the Vault secrets in secret/config.
I am unable to add secret fetching from multiple paths in Vault (secret/config + secret/customFolder). I have tried adding comma separated application-name etc as suggested across various posts but does not work. Has anyone tried something similar?
You can take a look to the composite profile.
There are a lot of additional questions - what exactly you are trying to do, and why do you want to have this?
For us, for example, it was important to split infra services configurations and also split, actually, microservices configurations by itself. And, important requirement, to be able to "overwrite" it (in case of migrations, for instance).
We have achieve that with two things:
on config server side we are using composite configuration (with exactly the same type and uri, but little bit different backend and keys),
on config client's side we are specifying several values for spring.cloud.config.name property (coma separated list).

How do I set environment properties in AWS codestar?

I created a spring project in AWS codestar.
I would like to pass environment properties to my application (e.g. DATA_SOURCE_URL). I can do it in elastic beanstalk in "Configuration" -> "Software" "modify" and adding the properties. But whenever a new deployment is triggered this configuration gets reseted.
I was wondering what is the way of setting environment properties when using AWS codestar.
As it may help other people that search a solution
I finally get it to work by using the Saved Configuration function in Beanstalk, and calling it via the cloud formation template.yml : EBConfigurationTemplate (from the autogenerated template.yml by codestar)
EBConfigurationTemplate:
[...]
SourceConfiguration:
ApplicationName: !Ref 'EBApplication'
TemplateName: "Saved Configuration Name"
After that my django application was able to read the os.environ['ENV_VAR_NAME']
as well as django.config that was able to connect to an RDS (Non-managed by beanstalk) to do the migration as a container_command

Spring cloud config with github

I just got a problem when using spring cloud config with github.I'm not really good at English,I hope I could explained this problem clearly.And thinks
you guys for reading this.
The problem is about Spring Cloud Config with github.And it happened when I added some more folds and config files to the repository where hold all my cloud config files.
First,I set uri,searchPaths,username,password under the cloud.config.server.git in the application.yml file belonged to config server.
Then,I push all my config files to the github.I called the parent repository ConfigRepo,and in this repo,I got two folders named A and B.
The construction is just look like this.
-ConfigRepo
-A
-A.yml
-B
-B.yml
Finally,I set the other applications' application name in their bootstrap.yml which means A and B.
After I've done that,I started my applications.All the client servers could find the config server and got the correct config yml file by the url.For example, the client A get its configs from
github.com/user/ConfigRepo/A/A.yml
But cause I needed to add a new application C,so I created a new folder C to hold and save the Application C's config file and push it to the github.
I finished the config work of application C just like above and start the it.But I found the url represent config file has changed.I mean,it suppose to be
github.com/user/ConfigRepo/C/C.yml
But in fact,the url of github has changed to
github.com/user/ConfigRepo/tree/master/C/C.yml
The worse thing is,not only the url represents C's config file has changed,all the url represents config file in the ConfigRepo has changed.
And no matter how i change the uri or searchPaths under cloud.config.server.git,the client server's log shows me that the name of located property source's mapPropertySource always is
github.com/user/ConfigRepo/C/C.yml
As a result,i cant get any configs except null so all the applications cant be started even include the A and B which could started before i pushed the new config file to the github.
So,what should I do?Is a way to make github get rid of /tree/master in the url?Or how to config my config server to support my project?
Thanks Again!
We are doing micro service project and used below configuration for retrieve configuration from GitHub. you need to add label as master to retrieve configuration.
spring:
application:
name: ####
profiles:
active: ####
cloud:
enable: true
config:
uri: ${CONFIG_SERVER_URL}
failFast: true
retry:
maxAttempts: 20
label: master
profile: ######

SpringBoot gitHub config server not able to read from folder in Repo

I was getting my hands into spring boot with using a git based config file.
This is my repo.
In here I have some config files inside tolls-config folder this does retrieve the config file
But when in the tutorial this repo is used it works
API call :
localhost:8888/s1rates/default
My Questions
Do I need to modify the API call
Should my uri be pointing to specific folder in repo( I tried putting folder URL and it gives a 500)
Every config file has to been its own repo ( there is no way
around it )
I loked at your repo and it seems that you misspelled the property for searchPaths instead of search-paths like you have in your config.
spring:
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
searchPaths: foo,bar*

loading multiple properties with config-server

I have successfully tested loading properties from SVN repository, currently in my config server i have provided the URI and default-label: trunk and i have application specific property under trunk. below is the contents of my consuming application's application.yml and able to pull the properties successfully
spring:
application:
name: foo-development
cloud:
config:
uri: http://localhost:${config.port:8888}
now i have a shared property in different folder thats shared across other applications as well, so how do i load this into my application along with my application specific
The spring.cloud.config.name property allows you to specify multiple application names separated by a comma, so all you have to do is change your application.yml to
spring:
application:
name: foo-development
cloud:
config:
uri: http://localhost:${config.port:8888}
name: foo-development,myshared
This will load both foo-development properties as well as myshared properties.
You can create a general application.yml in the root folder of SVN.
See the example config repo here:
https://github.com/spring-cloud-samples/config-repo
And here is an example consumer
https://github.com/spring-cloud-samples/customers-stores/blob/master/rest-microservices-store/src/main/resources/bootstrap.yml
The customer-stores project will read from application.yml and also from stores.yml in the repo.
To confirm, check the /env URL if you have actuator added and you should see two configService entries