kubefwd doesn't work for specific ports/hostnames

Viewed 176

I am using this command to run kubefwd (https://github.com/txn2/kubefwd)

sudo kubefwd services -x <context> -n <namespace> -c <kube_file_path> -l "app in (idm, sbb-amq)"

That is the log:


    INFO[14:13:58] Port-Forward: 127.1.27.1 sbb-amq:8161 to pod sbb-amq-0:8161
    INFO[14:13:58] Port-Forward: 127.1.27.1 sbb-amq:61616 to pod sbb-amq-0:61616
    INFO[14:13:58] Port-Forward: 127.1.27.1 sbb-amq:61616 to pod sbb-amq-0:61616
    INFO[14:13:58] Port-Forward: 127.1.27.7 idm:9006 to pod idm-0:9006
    INFO[14:13:58] Port-Forward: 127.1.27.7 idm:80 to pod idm-0:9006
    ERRO[14:14:01] ForwardPorts error: unable to listen on any of the requested ports: [{80 9006}]

I got an error in the last line of the log, so I have realized that all the hostnames related to ports 80 and 9006 were not attached to the IP, which means:

However:

  • http://sbb-amq:8161 works as well (not using the port 9006)

Has anyone seen this before?

EDIT: I am using Ubuntu and the ports 80/9006 are not in use.

1 Answers

unable to listen on any of the requested ports usually means that you have something on your local workstation listening on those ports, 0.0.0.0:80 and 0.0.0.0:9006 in this case. The IP 0.0.0.0 means it's listening to those ports on all interfaces.

kubefwd uses local loopback IP addresses to allow the same port for multiple services so that you can have 127.27.1.1:80 -> someservice:80 and 127.27.1.2:80 -> someotherservice:80.

Unfortunately, when you have local applications using 0.0.0.0:80, you will not be able to bind 80 to any interface, as it is already being used. I don't know why applications often bind to every interface since localhost almost always points to 127.0.0.1.

You have a couple of options:

  1. change the configuration of those other services to use a single IP such as 127.0.0.1
  2. use the mapping flag and have kubefwd use a differnt port: -m 80:8080 -m 9006:9007
Related