Can anyone provide me with the application.properties for the spring cloud config server?
eureka.client.registerWithEureka = true
eureka.client.fetchRegistry = true
eureka.client.serviceUrl.defaultZone = http://localhost:8761/eureka/
eureka.instance.hostname = localHost
I am quite confused about what to do for the GitHub part.
Related
I'm using spring-cloud-vault-config-databases with Spring Boot 2.4.0 Config Data API as the prefered mode described here bootstrap.yml configuration not processed anymore with Spring Cloud 2020.0 :
When I'm using Spring Boot 2.4.0 Config Data API to import configuration from Vault (Preferred) the secret properties are not binded to the spring.datasource.username & spring.datasource.password and my postgres cnx fails.
When I'm using "Legacy Processing" with the bootstrap configuration property spring.cloud.bootstrap.enabled=true the properties spring.datasource.username & spring.datasource.password are well binded to my Vault secret.
What is the expected behaviour of the spring-cloud-vault-config-databases ?
Is expected to works with Spring Boot 2.4.0 Config Data API ?
my application.yml
spring.cloud.vault:
enabled: true
authentication: CERT
ssl:
key-store: file: ...
key-store-password: ...
trust-store: ...
trust-store: ...
trust-store-password: ...
cert-auth-path: ...
uri: https:...
namespace: ...
fail-fast: true
database:
enabled: true
role: myPostgresRole
backend: database/postgres/...
username-property: spring.datasource.username
password-property: spring.datasource.password
spring:
config:
import: vault://secret/... , vault://database/postgres/...
Versions used :
spring-boot : 2.4.11
spring-cloud : 2020.0.3
spring-cloud-vault-config-databases : 3.0.3
For one of our customer, who is using Spring Boot version 2.0.0 Release, we have Spring cloud config server with native settings. For local development, we want to disable spring cloud config server so that other spring boot micro-services can use application-local.yml settings.
I tried below options but its not working
Setting spring.cloud.config.enabled=false in bootstrap.yml file
Setting -Dspring.profiles.active="local"
When I run the micro-services, it is still looking for config server. Any inputs.
Can not remove the dependency of config-starter reference in gradle file as a workaround
These are the configurations that worked for me. I'm using Eureka service to find where the config server is.
spring:
cloud:
config:
enabled: false
discovery:
enabled: false
eureka:
client:
enabled: false
to run the local service without loading props from any remote config server you need to disable the bootstrap file and config.
resources/bootstrap.yml --> resources/application.yml
with this springboot will load your application.yml by default.
I have question is there any way to retrieve certain values and inject them to bootstrap.yml while application is coming up.
I have configuration file like this:
spring:
application:
name: myApp
cloud:
consul:
enabled: true
host: localhost
port: 8500
config:
enabled: true
datasource:
url: jdbc:oracle:thin:#localhost:1111:XXXX
username: ${nameOfVariable1}
password: ${nameOfVariable1}
driver-class-name: oracle.jdbc.OracleDriver
For example, I need to configure embedded tomcat port, or DB credentials, I don't want to put it hardcoded in .yml properties file, instead I want to put some variable name in .yml so Spring will go and bring value from Consul. Is it possible?
You can use Spring Cloud Consul Config project that helps to load configuration into the Spring Environment during the special "bootstrap" phase.
3 steps:
add pom dependency: spring-cloud-starter-consul-config
enable consul config: spring.cloud.consul.config.enabled=true
add some config in consul kv in specific folder, such as key: config/testConsulApp/server.port, value:8081
and then start the sample web app, it will listen 8081.
more detail at spring cloud consul doc.
and demo code here
I try to use Consul as configuration server with Spring boot. I already succeed to use the kv store of consul to fetch variables, but now I want to be able to fetch variables as YAML files. Here is my bootstrap.yaml :
spring:
cloud.consul:
host: localhost
port: 8500
config:
enabled: true
format: YAML
failFast: true
I put this config on consul on the path "/config/my.application.name/data" :
testspring: hello
And I try to reach this property using :
#Value("${testspring}")
... with no success.
What am I missing here ? What is the good path for config on consul ?
Thanks
EDIT :
It appears that the config is loaded on the value ${data} and that it is not parsed. The data="testspring: hello", which is not what is expected.
I was able to fetch data using your sample. But if I remove format: YAML (so use default KEY_VALUE) from my config then not parsed data property is fetched.
Maybe double check your bootstrap.yml config for correct indentations.
What version of Spring Boot and Spring Cloud you are using ?
Eureka does not recognized HTTPS endpoints like '/info' and '/health' and always points to HTTP endpoints after enabling HTTPS. How to enable HTTPS micro-service url registration at Eureka ?
You have to explicitly define these URLs as Eureka always points to HTTP internally. Read Here for more about it.
You can add following into your yaml file in the microservice.
eureka:
instance:
nonSecurePortEnabled: false
securePortEnabled: true
statusPageUrl: 'https://${eureka.instance.hostName}:${server.port}/info'
healthCheckUrl: 'https://${eureka.instance.hostName}:${server.port}/health'
homePageUrl: 'https://${eureka.instance.hostName}:${server.port}/'
Here "eureka.instance.hostName" and "server.port" values will be taken from the environment.
For me this configuration works:
eureka:
instance:
nonSecurePortEnabled: false
securePortEnabled: true
securePort: ${server.port}
statusPageUrl: https://${eureka.instance.hostname}:${eureka.instance.securePort}/info
homePageUrl: https://${eureka.instance.hostname}:${eureka.instance.securePort}/
For me below configuration works fine:-
eureka:
instance:
statusPageUrl: https://${eureka.hostname}:${server.port}/actuator/info
healthCheckUrl: https://${eureka.hostname}:${server.port}/health
homePageUrl: https://${eureka.hostname}:${server.port}/