Consul agent to join a server on k8s aws by using nodeport and the aws provider

Hi there!

I got Consul deployed in EKS via HELM. So far so good.
I got into figuring out the best way to connect external agents (clients) to my cluster, which I decided to be using nodeport to expose the service on each node.

Now I got all the networking done except than when using the following retry-join option:
"retry_join": [“provider=aws tag_key=Name tag_value=my-tag”]

The problem is:
* Failed to join my_server_ip: dial tcp my_server_ip:8301: connect: connection refused

Since the nodeport exposed is 30301, then my server can’t be found.
I was not able to find a way to specify the port to be used by a agent to connect to a server.

I know that I can use a proxy to get that sorted out (I was thinking on Apache or Nginx), but is there a way to tell the agent to look for the server on a custom port?

Thanks in advance!

I was able to make it work with nginx on the nodes:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

stream {
# …
server {
listen 8300;
proxy_pass 127.0.0.1:30300;
}
server {
listen 8301;
proxy_pass 127.0.0.1:30301;
}
server {
listen 8302;
proxy_pass 127.0.0.1:30302;
}
server {
listen 8600;
proxy_pass 127.0.0.1:30600;
}
}

But seems that there should be a consul type solution like being able to tell the agents to connect to a certain port instead the default ones.

Hi, I don’t think there’s a way to set a custom port unfortunately. You could set up a DNS entry that points to your server IPs and the use hostname:30301.

I think this can be closed, given my services change IP’s I can figure it out via the autojoin for AWS with Nginx for the ports.