This Service is a personilzed implementation of Eureka and acts as a discovery hub for any microservice that sends its registration signature.
- Register microservices
- Send updated information about the registered microservices
The Configuration Service uses a number of open source projects to work properly:
The Configuration Service requires Docker v18+ to run.
Once Docker is installed you can build from source or use the predefined images available at Docker Hub
Using gradle wrapper:
cd discovery-service
./gradlew clean build
docker-compose -f docker-compose-local.yml up --build
This will build the application and generate the jar file to be placed in a container and also run a personalized version of Eureka called discovery-service.
The Configuration Service is very easy to run from the images on Docker Hub.
By default, Docker will expose port 8888. You can change this within the docker-compose.yml file if necessary.
cd configuration-service
docker-compose up
In order for the Java Spring client applications register themselves in the discovery service, they need to have the following configurations in Application.java, application.yml and gradle.build.
The @EnableEurekaClient
annotation must be present in the main Application.java.
...
@EnableEurekaClient
public class Application {
...
The application.yml file needs to be configured as instructed below:
eureka:
instance:
preferIpAddress: true
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://${DOCKER_MACHINE_IP:discoveryservice}:8761/eureka/
The build.gradle file must contain the next configuration:
ext {
springCloudVersion = 'Edgware.SR2'
}
...
dependencies {
...
compile('org.springframework.cloud:spring-cloud-starter-eureka')
...
}
...
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}