Spring cloud config local and remote repositories for different profiles - spring

I'm trying to setup my application with multiple repositories - a local file based one for development/testing purpose and a remote git repo for production.
I am using the following yaml for this purpose -
spring:
application:
name: localRepoConfig
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
repos:
development:
pattern:
- '*/development'
- '*/staging'
uri: https://github.com/development/config-repo
native:
searchLocations: classpath:/config
server:
port: 8888
This is not working however, the following works for the local repo -
spring:
application:
name: localRepoConfig
profiles:
active: native
cloud:
config:
server:
native:
searchLocations: classpath:/config
server:
port: 8888
I have not been able to make the two repositories function, after following the Spring documentation and a few posts here.
Would greatly appreciate if someone can point me in the right direction.

I got this working with the following config in bootstrap.yml -
spring:
application:
name: localRepoConfig
profiles:
active: native
cloud:
config:
server:
native:
searchLocations: classpath:/config
server:
port: 8888
---
spring:
profiles: development
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
server:
port: 8989
I am able to switch between the native and development profiles now.
The following guide was quite helpful -
kubecloud.io/guide-spring-cloud-config/

Based on the documentation on Spring Cloud Config it sounds like native and git are mutually exclusive and that you can't use both for a single config server.

Related

How to access multiple application yml from difference service on configure server(Spring)

I have configured "configure-server" by fetching all configuration from gitlab repository.
Currently, when application(config-server) start it fetch all application properties in git repo.
In case, I have two client application A,B
which has difference application properties like
aplication-a.yml
aplication-b.yml
when application A start, I just only want configure-service fetch only application-a.yml from git repositry.
Here is application configure:
Configure Server
server:
port: 9000
spring:
application:
name: CONFIG-SERVER
cloud:
config:
server:
git:
uri: https://gitlab.com/mama/cloud-configure-server.git
clone-on-start: true
default-label: main
Application A
spring:
cloud:
config:
enabled: true
uri: http://localhost:9000
How to tell configure-service fetch only application-a.yml from git repository?
In case, I don't want to fetch all?
Thank you!!

How to use application.propeties in spring cloud config client application?

How to use application.yml in spring cloud config client application?
spring:
application:
name: app-cli
profiles:
active: DEV
config:
import: "configserver:"
cloud:
config:
name: ${spring.application.name}
uri: http://192.168.0.12:8888
username: thirumal
password: thirumal
request-read-timeout: 200
request-connect-timeout: 100
fail-fast: true
The client app is configure with all the required properties, still it's not connecting to config-server.
The lib implementation 'org.springframework.cloud:spring-cloud-starter-config'

Adding multiple repositories to Spring cloud config server

I need to add two config repositories to my config server. But, it picks only one config repository. Can anyone please help me to fix this problem.
Config Server bootstrap.yml
server:
port: 8899
spring:
cloud:
config:
server:
git:
uri: https://github.com/pocuser9x/wednest-config-store
search-paths:
- 'wednest-config-store/*service'
repos:
uri: https://github.com/pocuser9x/secure-config-store
In https://github.com/pocuser9x/wednest-config-store I have below files
event-service.yml
event-service-dev.yml
event-service-stg.yml
These files are picking correctly.
In https://github.com/pocuser9x/secure-config-store I have below file
event-service-prod.yml
This file is not picking.
I think what you are looking for is the composite repo feature. It is documented here.
For you, this would be something like:
spring:
profiles:
active: composite
cloud:
config:
server:
composite:
-
type: git
uri: https://github.com/pocuser9x/wednest-config-store
search-paths:
'wednest-config-store/*service'
-
type: git
uri: https://github.com/pocuser9x/secure-config-store
One note is that the documentation shows profile set as above, but I found a need to use "include" instead of "active". Include is additive.
profiles:
include: composite

spring cloud config with github backend

I am struggling to fix this issue.
I am trying to use the spring cloud-config with github repo but it not fetching any config.
The server is working fine with file-based configuration but not working with GIT.
spring:
profiles:
active: native
cloud:
config:
discovery:
enabled: false
server:
git:
uri: https://github.com/${GIT_USER}/config-server
searchPaths: organizationservice,personservice,zuulservice
username: ${GIT_USER}
password: ${GIT_PASS}
skipSslValidation: true
cloneOnStart: true
Boot and cloud version
springBootVersion = '2.1.7.RELEASE'
springCloudVersion= "Greenwich.SR2"

Spring Cloud Config Server with Vault - vault overrides any value from native profile

I am trying to mix native and vault profile with config server backend:
spring:
profiles:
active: native, vault
cloud:
config:
server:
native:
searchLocations: classpath:/abc
vault:
kv-version: 2
when I start config server I curl for properties:
curl -X "GET" "http://localhost:20000/appName/dev" -H "X-Config-Token: xxxxxxxx"
I got empty propertySources list:
{"name":"appName","profiles":["dev"],"label":null,"version":null,"state":null,"propertySources":[]}%
but when I change my bootstrap file (remove vault profile):
spring:
profiles:
active: native
cloud:
config:
server:
native:
searchLocations: classpath:/abc
vault:
kv-version: 2
It works: returning my properties:
{"name":"appName","profiles":["dev"],"label":null,"version":null,"state":null,"propertySources":[{"name":"classpath:/abc/appName-dev.yml","source":{"some.properties":"VALUE","....}
I did tried with "order" flags but still nothing...
The only workaround I found is bootstrap with "composite" profile like this:
spring:
profiles:
active: composite
cloud:
config:
server:
composite:
-
type: vault
kv-version: 2
-
type: native
searchLocations: classpath:/abc
But still don't know why it does not work with multi profile configuration, and why vault is overriding my native properties....

Resources