Communication between consul on local VM and consul in Kubernetes

So this retry-join ‘provider=k8s label_selector=“app=consul,component=server”’ will always use the pod ips. It won’t use the node ips. For that to return the node ips you need to run the server pods in hostNetwork mode so that their pod ip is actually the node IP.

Or you can use a DNS entry instead that resolves to each server IP.

It’s important to note that you can’t use a NodePort service because that causes the requests to be randomly load balanced across all the servers. Each consul client needs to be able to talk directly to a specific server. So you’d need to expose the servers using a hostPort, not a service. Then when the client talks to server1-ip:<port> it doesn’t have its request randomly load balanced to another server pod, that IP/port always routes to server1.