I am working with a group of microservices developed with Java + Spring Boot and would like to use Consul and KrakenD inside a Docker compose.
My docker-compose file looks like this:
version: '3.8'
services:
# Consul
# Service discovery similar to Eureka but could keep configuration
consul:
image: consul
container_name: consul
command: agent -server -ui -node=server1 -bootstrap-expect=1 -client=0.0.0.0
environment:
- CONSUL_BIND_INTERFACE=eth0
ports:
- "8500:8500"
- "8600:8600/udp"
- "8600:8600/tcp"
hostname: "consul"
networks:
- micros
krakend:
image: devopsfaith/krakend
container_name: krakend
volumes:
- ./krakend:/etc/krakend
ports:
- "1234:1234"
- "8080:8080"
- "8090:8090"
networks:
- micros
google-search-service:
environment:
- JAVA_OPTIONS=-Dlogging.level.net.leyba.googlesearch=INFO
image: google-search-service
container_name: google-search-service
#ports:
# - "7000-7200"
networks:
- micros
depends_on:
consul:
condition: service_started
# krakend:
# condition: service_started
networks:
micros:
and the KrakenD config file looks like this:
{
"version": 2,
"extra_config": {
"github_com/devopsfaith/krakend-gologging": {
"level": "ERROR",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true,
"format": "default"
}
},
"timeout": "3000ms",
"cache_ttl": "300s",
"output_encoding": "json",
"name": "googlesearch",
"port": 8080,
"endpoints": [
{
"endpoint": "/v1/googlesearch/{searchParam}",
"method": "GET",
"output_encoding": "json",
"extra_config": {},
"backend": [
{
"sd": "dns",
"url_pattern": "/external-dbs/google/{searchParam}",
"host": [
"google-search-service.service.consul"
],
"disable_host_sanitize": true
}
]
},
]
}
Whithout docker, the host google-search-service.service.consul is resolved through a resolver in my macOS, however it seems that could not be resolved inside the docker-compose network and therefore Krakend is not able to redirect API calls to the microservice because is not able to find Consul.
I am wondering if is there a way to config a resolver inside the docker-compose or to allow KrakendD to found Consul in any other way.
Thanks in advance J