Spring Cloud Config Server - Bitbucket Session - spring

I’m trying to solve an awkward problem with Spring Cloud Config Server via Bitbucket.
My config repo on Bitbucket Cloud Server. bootstrap.yaml file looks like below.
server:
port: 9101
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: https://****#bitbucket.org/****/config-repo.git
username: ***
password: ****
skip-ssl-validation: true
clone-on-start: true
force-pull: true
basedir: /tmp
eureka:
client:
service-url:
defaultZone: ${EUREKA_SERVER_ADDRESS}
register-with-eureka: true
The config-server fetched all properties from bitbucket and write to the /tmp file after app is started.
There is no exception or no warning. Everything is fine.
I’m getting an error looks like below after a few hours later, the app trying to fetch from bitbucket to update all properties.
2020-12-22 12:08:55.865 INFO 1 --- [nio-9101-exec-5] o.s.c.c.s.e.NativeEnvironmentRepository : Adding property source: file:/tmp/salesart-spm-prod.properties
2020-12-22 12:08:56.936 WARN 1 --- [nio-9101-exec-7] .c.s.e.MultipleJGitEnvironmentRepository : Could not fetch remote for master remote: https://****#bitbucket.org/***/config-repo.git
I guess the problem is about the Bitbucket Session. Why did I thought like this?
Because after successfully logged in to bitbucket server via username and password, the app fetching all properties.
Then, a few hours later I’m getting same error.
Do you have any idea to solve this problem?

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!!

Invalid config server configuration

I am on learning stage of Spring Cloud & using spring version 2.4.3 and spring-cloud-version
2020.0.1 and I created two property file
application.yml
spring:
application:
name: cloud-server
server:
port: 8888
bootstrap.yml
spring:
cloud:
config:
server:
git:
uri: https://github.com/************/insurance-config-server
default-label: main
but still I got following error
***************************
APPLICATION FAILED TO START
***************************
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
How to solve this kind of error?
Did you have a bootstrap.yml file?
I had the same problem. My project did not have a bootstrap.yml, but I specified a dev activity file in the IDEA startup configuration, which caused the same error as you did. The error could not be found bootstrap.yml on startup. After deleting dev in IDEA startup configuration, it can start normally.
If you are following the example in the book you referenced then I will suggest you move this
spring:
cloud:
config:
server:
git:
uri: https://github.com/************/insurance-config-server
default-label: main
to application.yml
That is what I did and it worked for me

When spring config server is down and GIT under maintenance and spring config client at the initial startup

Spring Config-Client is in initial startup so It would not have cached the data from config server,
if either Config-Server or GIT or both are down - what can be done in that case to get the data and maintain service availability.
You can use the following (basedir) element of yml file with following hierarchy.
The "basedir" element will cache your config data whenever application restarts and keep that on the specified path which is specified against this key as a value.
Example :
basedir : C:\POC_CONFIG_SERVER\config-repo-am
server:
port: 8888
spring:
application:
name: cloud-config-server
cloud:
config:
server:
git:
uri: ${uri}
force-pull: true
skip-ssl-validation: true
skipSslValidation: true
username: ${username}
password: '${password}'
default-label: master
basedir: ${basedir}

Is is possible to configure multiple git repositories in Spring Cloud Config Server

I would like to read some configurations from multiple git repositories, something like:
spring:
profiles:
active: base, app1, app2
cloud:
config:
server:
base:
uri: http://${GIT_HOST}/base/base.git
username: ${GIT_USERNAME}
password: ${GIT_PASSWORD}
app1:
uri: http://${GIT_HOST}/group1/app1.git
username: ${GIT_USERNAME}
password: ${GIT_PASSWORD}
app2:
uri: http://${GIT_HOST}/group2/app2.git
username: ${GIT_USERNAME}
password: ${GIT_PASSWORD}
At startup I see the following exception:
Caused by: java.lang.IllegalStateException: You need to configure a uri for the git repository
The documentation shows an example using two different repos, git and svn. Can't we use multiple repos of the same kind?
Due to the link of document you said, the svn and git after server is the type, not profile. So you cannot use base, app1, app2.
But in your case, I think you can use this kind of config: document link.
spring:
cloud:
config:
server:
git:
uri: https://git/common/config-repo.git
repos:
team-a:
pattern: team-a-*
cloneOnStart: true
uri: http://git/team-a/config-repo.git
team-b:
pattern: team-b-*
cloneOnStart: false
uri: http://git/team-b/config-repo.git
team-c:
pattern: team-c-*
uri: http://git/team-a/config-repo.git

Spring cloud config local and remote repositories for different profiles

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.

Resources