How to enable remote access to Master's proxy - "Failed connect to <ip>:8080; Connection refused"

7/15/2018

I am playing with Kubernetes on https://labs.play-with-k8s.com.
I tried to use the kubectl proxy following the instructions in Kubernete's website.
On the Master node (192.168.0.13) I ran: kubectl proxy --port=8080:

[node1 ~]$ kubectl proxy --port=8080
Starting to serve on 127.0.0.1:8080

On the Worker node I ran curl -v http://192.168.0.13:8080 and it failed:

[node2 ~]$ curl -v http://192.168.0.13:8080
* About to connect() to 192.168.0.13 port 8080 (#0)
*   Trying 192.168.0.13...
* Connection refused
* Failed connect to 192.168.0.13:8080; Connection refused
* Closing connection 0
curl: (7) Failed connect to 192.168.0.13:8080; Connection refused

Any idea why the connection is refused ?

-- E235
kubernetes
proxy

1 Answer

7/16/2018

Starting to serve on 127.0.0.1:8080

As shown in the message it emits on startup, that is because kubectl proxy only listens on localhost (i.e. 127.0.0.1), unless you instruct it otherwise:

kubectl proxy --address=0.0.0.0 --accept-hosts='.*'

and that --accept-hosts business is a regular expression for hosts (presumably Referer headers? DNS lookups?) from which kubectl will accept connections, and .* is a regex that matches every string including the empty ones.

-- mdaniel
Source: StackOverflow