Hi,
I’m using Tyk as gateway for some microservices in AWS using Eureka as service discovery. One problem I have is that we use autoscaling where we scale the number of microservice instances in AWS from one to many, depending on load. When there are many instance, eureka will return a json with a list of instances, like this :
{
"application": {
"name": "ROUTE",
"instance": [
{
"hostName": "ip-172-31-57-136",
...
},
...
{
"hostName": "ip-172-31-13-37",
...
}
],
...
}
}
but if we only have one instance, eureka will return json like this, i.e. no list:
{
"application": {
"name": "ROUTE",
"instance": {
"hostName": "ip-172-31-57-136",
...
},
...
}
}
In the Tyk API, it doesn’t seem possible to set up something than handles both cases dynamically, since if it’s set up to receive a list, it will fail when it doesn’t receive one, and vice versa. Or is there something I’m missing?
If it’s not possible, are there any workarounds, e.g. with endpoint designer?
For reference, the service discovery configuration I’m using for multiple instances :
{
...
"proxy": {
...
"service_discovery": {
"use_discovery_service": true,
"query_endpoint": "http://X.X.X.X/eureka/",
"use_nested_query": false,
"parent_data_path": "application.instance",
"data_path": "hostName",
"port_data_path": "",
"target_path": "",
"use_target_list": true,
"cache_timeout": 60,
"endpoint_returns_list": false
}
},
...
}
versus the configuration I use for a single instance:
{
...
"proxy": {
...
"service_discovery": {
"use_discovery_service": true,
"query_endpoint": "http://X.X.X.X/eureka/",
"use_nested_query": false,
"parent_data_path": "",
"data_path": "application.instance.hostName",
"port_data_path": "",
"target_path": "",
"use_target_list": false,
"cache_timeout": 60,
"endpoint_returns_list": false
}
},
...
}