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"?
Related
So, I am learning about microservices (I am a beginner) and I'm facing an issue. I've went through the Spring Cloud Config and Docker docs hoping to find a solution, but I didn't.
I have an app with 3 microservices (Spring Boot) and 1 config server (Spring Cloud Config). I'm using a private Github repository for storing config files and this is my application.properties file for config server:
spring.profiles.active=git
spring.cloud.config.server.git.uri=https://github.com/username/microservices-config.git
spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.default-label=master
spring.cloud.config.server.git.username=${GIT_USERNAME}
spring.cloud.config.server.git.password=${GIT_ACCCESS_TOKEN}
I have a Dockerfile based on which I have created a Docker image for config server (with no problems). I created a docker-compose.yml which I use to create and run containers, but it fails because of an exception in my cloud config app. The exception is:
org.eclipse.jgit.api.errors.TransportException: https://github.com/username/microservices-config.git: not authorized
Which basically means that my environment variables GIT_USERNAME and GIT_ACCCESS_TOKEN (that I set up in Intellij's "Edit configuration" and use in application.properties) are not available for the config server to use in a container.
The question is: Do I need to somehow add those environment variables to .jar or to Docker image or to Docker container? Like I'm not sure how do I make them available for the config server to use in a container.
Any help or explanation is welcomed :)
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.
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}
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
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