我正在https://labs.play-with-k8s.com上与Kubernetes一起玩。
我尝试按照Kubernete's website中的说明使用kubectl proxy
。
在主节点(192.168.0.13)上,我运行:kubectl proxy --port=8080
:
[node1 ~]$ kubectl proxy --port=8080
Starting to serve on 127.0.0.1:8080
在Worker节点上,我运行curl -v http://192.168.0.13:8080
并失败:
[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
有人知道为什么拒绝连接吗?
答案 0 :(得分:1)
开始在127.0.0.1:8080上投放
如启动时发出的消息中所示,这是因为kubectl proxy
仅监听localhost(即127.0.0.1
),除非您另行指示:
kubectl proxy --address=0.0.0.0 --accept-hosts='.*'
并且该--accept-hosts
业务是主机的正则表达式(大概是Referer
标头?DNS查找?),kubectl
将从中接受连接,而.*
是一个正则表达式匹配每个字符串,包括空字符串。