I hope someone else has had the same issue, merely for my own sanity sake.
Quick TL/DR
We make use of consul connect sidecars between all our nomad defined services.
Everything works great, except that we need to connect to two external services. Azure-hosted Redis and Postgresql
For this, we defined two terminating gateways, one for each endpoint.
Here is where things go off the rails:
- If more than one service needs to talk to Redis, only the service that starts up first can connect via the Terminating Gateway. All other subsequent services fail.
- A single service, with a single instance, connects to PostgreSQL via the Terminating gateway. Push a new job definition via Nomad, causing the service to restart, the new version fails to connect. The only way around this is defining the terminating gateway via the consul CLI again
- Similar to the above… A single service, with multiple instances, only the first instance can connect.
I tested the above with a self-hosted Redis instance and did not have the issues. At the moment it seems it is only for the instances hosted in Azure.
Any suggestions? Comments? Feedback?
The boring bits:
How I define the external Node:
Definition file, node.json:
{
“Node”: “azure-redis”,
“Address”: “redis-cache.redis.cache.windows.net”,
“Service”: {
“ID”: “azure-redis”,
“Service”: “azure-redis”,
“Port”: 6379
}
curl --request PUT --data @node.json http://127.0.0.1:8500/v1/catalog/register
Defining the service, that references the node:
Definition File, service.json:
Kind = “terminating-gateway”
Name = “redis-termination-gateway”
Services = [
{
Name = “azure-redis”
}
]
consul config write service.json