I have configured a spring cloud gateway to redirect to a server a created with the following route:
@Bean
public RouteLocator myRoutes(RouteLocatorBuilder builder) {
return builder.routes()
.route(p -> p
.path("/v1/**")
.uri("lb://data-diff-service"))
.build();
}
It works fine on a local environment, but when I start my services containers through my docker-compose file, the gateway is not able to find the customer-service. It works fine when running locally outside the containers
version: "3.4"
services:
registry-service:
image: project/registry-service
hostname: registry-service
ports:
- "8761:8761"
gateway:
image: project/gateway
hostname: gateway
ports:
- "8080:8080"
environment:
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://registry-service:8761/eureka
data-diff-service:
image: project/data-diff-service
hostname: data-diff-service
environment:
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://registry-service:8761/eureka
SPRING_DATA_MONGODB_URI: mongodb://teste:teste@mongo-database:27017/data_diff?retryWrites=true&w=majority
I'm testing it on the localhost 8080 port. The data-diff-service can communicate normally with Mongo db that runs in a separate container
EDIT result from http://:8761/eureka/apps:
<applications>
<versions__delta>1</versions__delta>
<apps__hashcode>UP_2_</apps__hashcode>
<application>
<name>GATEWAY</name>
<instance>
<instanceId>gateway:localhost:2ba2ecb7caf0931ba4b5580138cd3817</instanceId>
<hostName>localhost</hostName>
<app>GATEWAY</app>
<ipAddr>172.20.0.4</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">8080</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1615821410991</registrationTimestamp>
<lastRenewalTimestamp>1615821560153</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1615821410308</serviceUpTimestamp>
</leaseInfo>
<metadata>
<management.port>8080</management.port>
</metadata>
<homePageUrl>http://localhost:8080/</homePageUrl>
<statusPageUrl>http://localhost:8080/actuator/info</statusPageUrl>
<healthCheckUrl>http://localhost:8080/actuator/health</healthCheckUrl>
<vipAddress>gateway</vipAddress>
<secureVipAddress>gateway</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1615821410991</lastUpdatedTimestamp>
<lastDirtyTimestamp>1615821410126</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>
<application>
<name>DATA-DIFF-SERVICE</name>
<instance>
<instanceId>data-diff-service:localhost:2477c80c3a1b51f6af76fc02013be957</instanceId>
<hostName>localhost</hostName>
<app>DATA-DIFF-SERVICE</app>
<ipAddr>172.20.0.5</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">37069</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1615821441412</registrationTimestamp>
<lastRenewalTimestamp>1615821441412</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1615821440902</serviceUpTimestamp>
</leaseInfo>
<metadata class="java.util.Collections$EmptyMap"/>
<homePageUrl>http://localhost:37069/</homePageUrl>
<statusPageUrl>http://localhost:37069/actuator/info</statusPageUrl>
<healthCheckUrl>http://localhost:37069/actuator/health</healthCheckUrl>
<vipAddress>data-diff-service</vipAddress>
<secureVipAddress>data-diff-service</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1615821441412</lastUpdatedTimestamp>
<lastDirtyTimestamp>1615821440865</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>
</applications>
I've lost a day on it, could anyone help?