Consul DNS - Avoid cross-zone traffic


I have huge app in Kubernetes with about 90 containers on 5 k8s worker nodes. Nodes are spread between Availability Zones in AWS, like that:

node1 - AZ-A
node2 - AZ-A
node3 - AZ-B
node4 - AZ-B
node5 - AZ-C

Also I got many small apps which use API from that huge app. All apps use external/public host of that app, so actually all traffic between apps goes through ELB.

I can use internal kubernetes hostnames like “api.api_namespace.svc.cluster.local” (now we got coreDNS), but I would like to avoid cross-zone traffic, so how can I implement consul to be AZ aware and prefer traffic between pods in the same AZ, e.g.

enter image description here

Something similar but with HAProxy and Redis:

Hi @pdomagala,

I wanted to get some additional clarification on your environment so that I can best answer your question.

Are you using Consul, or CoreDNS for name resolution within the cluster? Are you using Consul service mesh in this environment?