How does Spring Config Server Fetch Values from Git using Queues - spring

I am doing a course from Udemy, and implemented Spring Cloud Config Server, with Git as Backend. Every thing seems to be working fine.
I have following Spring Cloud Config Server: ConfigServer-RI
In ConfigServer-RI I have following entry in application.properties file, for configuring rabbit mq.
spring.cloud.config.server.git.uri=https://github.com/Naresh-Chaurasia/ConfigServer-RI
spring.cloud.config.server.git.default-label=main
spring.cloud.config.server.git.clone-on-start=true
management.endpoints.web.exposure.include=bus-refresh
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
I also have User Microservice: User-RI
In User-RI, I have following entry in application.properties
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
Now if i make change in applicaiton.properties in Git file, https://github.com/Naresh-Chaurasia/ConfigServer-RI, and then call, the Spring Config Server, with following URL http://localhost:8012/actuator/bus-refresh, the changes that are done in the Git properties file are reflected in User-RI Microservice i.e. the changes from Git repository properties file are accessible to User-RI Microservice without restarting it.
Question: I am not able to understand, how the data is flowing from Git Repository to Microservices, when I configure the queue details in application.properties file.
Thanks.

Related

Spring Boot Logging Config External File with Password

I have config server and I store my logbook.xml here. My config server integrated with my git repo and it has username-password.
I want to get related logback file from config server but it return 401.
I should add my user informations. How should I solve it
My YML file:
logging:
config: ${myRepo}

How to configure Spring Cloud Config Server to use cloned configuration files

My application.properties files of my Cloud Config Server looks like this.
config.source=Local Cloud Server #just to check where config come from
server.port=8012
encrypt.key=xxxxxxxxxxxxxx
spring.profiles.active=staging
spring.application.name=my-config-server
# Git Backend
spring.cloud.config.server.git.username=MY_USERNAME
spring.cloud.config.server.git.password=ghp_MY-DEV-ACCESS-TOKEN
spring.cloud.config.server.git.uri=https://github.com/my-username/app-config
spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.basedir=file://${user.dir}/cloned_configurations
On startup a new folder "cloned_configuration" is created inside of Cloud Config Server folder. I see all of my propertie files cloned form github with correct values.
But for some reason none of these are used. For e.g config.source must have the value "GitHub" because the cloned application.repository has an entry
config.source=GitHub
But on application start I see "Local Cloud Server". All other settings are also not used from cloned properties.
With Postman I can receive all Configs without any issues. But none of theme are used by my Config Server or any of my other webservices.All webservices and the config server using their own application.properties file.
What I do wrong?
You probably need to move your config server properties into your bootstrap.properties file instead of application.properties.
spring.cloud.config.server.git.username=MY_USERNAME
spring.cloud.config.server.git.password=ghp_MY-DEV-ACCESS-TOKEN
spring.cloud.config.server.git.uri=https://github.com/my-username/app-config
spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.basedir=file://${user.dir}/cloned_configurations
https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_client.html

Spring cloud config server git-uri local file resolves to master

In my app's bootstrap.yml file i have placed this configurations
spring:
application:
name: arun-test
cloud:
config:
server:
bootstrap: ${LOCAL_CLOUD_CONFIG_BOOTSTRAP:false}
git:
uri: file:${LOCAL_CLOUD_CONFIG_DIR}
I clone my properties folder from Github and then before starting the app, i turn my spring-boot app in to config server with below commands
export LOCAL_CLOUD_CONFIG_BOOTSTRAP=true
export LOCAL_CLOUD_CONFIG_DIR=/Users/arun/arunLabs/app-properties
./gradlew bootrun // to start
This works exactly fine.. But when i create a new branch and change the properties there to test something, the app always resolves to master-branch only and then it is still using my old configurations. Not going in to my branch
Not only that, it also replaces my file in the new branch with the one that is in master.
How to test it against my branch ?
Actually what you're looking for is a client side request. Cloud config will serve all branches in your repository.
You can read in the documentation.
You can either set the label value on your spring cloud Config Client
spring.cloud.config.label=newBranch
Or you can request directly to cloud config service
localhost:8080/{application}/{profile}/newBranch

Spring cloud Config Vault doesn't recognize comma separated application names

I'm setting a spring boot application that obtains its properties from a spring cloud config server application pointing to a Git config repository and to a Vault server.
Spring cloud config server application.properties:
spring.config.name=configserver
server.port=8888
spring.profiles.active=git,vault
# Config repository
spring.cloud.config.server.git.uri=...
spring.cloud.config.server.git.username=...
spring.cloud.config.server.git.password=...
spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.default-label=local
spring.cloud.config.server.git.searchPaths={application}
# Vault connexion
spring.cloud.config.server.vault.port=8200
spring.cloud.config.server.vault.host=127.0.0.1
Spring client bootstrap.properties:
spring.application.name=app1
spring.profiles.active=local
server.port=8082
spring.cloud.config.uri=http://localhost:8888
spring.cloud.config.token=...
Like this, it works well for getting configuration properties from Git and Vault, but if in bootstrap.properties I use a comma-separated list for "spring.application.name" like:
spring.application.name=app1,app2
This only works for getting config properties from Git but no from Vault.
How can I make Spring config server to make Vault recognizes more than one folder, like in this case "secret/app1" and "secret/app2"?

Config server not able to find the remote application file

I'm having issue with referring the application/config file on a config server.
I already have a GAIA DEV Pool ready.
This is what I have done so far -
Created an application.yml file with required config property
hello-service:
message: Hello World From Spring Cloud Config Server
Checked it in git repo - feature/cs-hello branch.
Logged in to dev pool cf login -a [dev-pool-url]
Created the config server :
cf create-service -c "{\"git\": { \"label\": \"feature/cs-hello\", \"uri\": \""[GIT HTTPS URL]\", \"username\": \"[USERNAME]\", \"password\": \"[PASSWORD]\" } }" p-config-server standard config-server
Now, my referring [https://docs.pivotal.io/spring-cloud-services/1-4/common/config-server/configuring-with-git.html] - since my config file is not on the master branch, I used label.
Somehow my code is not finding the application file on config server.
Anyone here who can point me a direction?
Once you are done with config server creation, you need to bind that service with your application and you can need to provide following information in bootstrap.yml
spring:
application:
name: appName
There is a way to check either your config server is connecting to repository or not. Go to
PCF manager -->Services--> Config Server--> Manage
and then you should be able to see
Config server is online

Resources