Kubernetes 如何为“设置正确的端口”;kubectl港前进“;(奇怪地转到localhost:8080)

Kubernetes 如何为“设置正确的端口”;kubectl港前进“;(奇怪地转到localhost:8080),kubernetes,istio,Kubernetes,Istio,我通过kubeadm安装kubernetes,然后关闭并再次引导。 然后,只有kubectl端口转发不起作用 下面的命令起作用 kubectl top nodes 但是kubectl port forward失败了。有什么建议吗? 似乎只有端口转发到本地主机:8080。 不起作用 sudo kubectl port-forward -n istio-system svc/istio-ingressgateway 80:80 --address 0.0.0.0 以下是正常模式下的日志 The

我通过kubeadm安装kubernetes,然后关闭并再次引导。 然后,只有
kubectl端口转发
不起作用

下面的命令起作用

kubectl top nodes
但是kubectl port forward失败了。有什么建议吗? 似乎只有端口转发到本地主机:8080。 不起作用

sudo kubectl port-forward -n istio-system svc/istio-ingressgateway 80:80 --address 0.0.0.0
以下是正常模式下的日志

The connection to the server localhost:8080 was refused - did you specify the right host or port?
用于调试模式日志

I0930 01:44:46.904299   47718 round_trippers.go:423] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.17.12 (linux/amd64) kubernetes/5ec4722" 'http://localhost:8080/api?timeout=32s'
I0930 01:44:46.904927   47718 round_trippers.go:443] GET http://localhost:8080/api?timeout=32s  in 0 milliseconds
I0930 01:44:46.904948   47718 round_trippers.go:449] Response Headers:
I0930 01:44:46.904987   47718 cached_discovery.go:121] skipped caching discovery info due to Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
I0930 01:44:46.905009   47718 shortcut.go:89] Error loading discovery information: Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
I0930 01:44:46.905067   47718 round_trippers.go:423] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.17.12 (linux/amd64) kubernetes/5ec4722" 'http://localhost:8080/api?timeout=32s'
I0930 01:44:46.905222   47718 round_trippers.go:443] GET http://localhost:8080/api?timeout=32s  in 0 milliseconds
I0930 01:44:46.905240   47718 round_trippers.go:449] Response Headers:
I0930 01:44:46.905263   47718 cached_discovery.go:121] skipped caching discovery info due to Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
I0930 01:44:46.905325   47718 round_trippers.go:423] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.17.12 (linux/amd64) kubernetes/5ec4722" 'http://localhost:8080/api?timeout=32s'
I0930 01:44:46.905465   47718 round_trippers.go:443] GET http://localhost:8080/api?timeout=32s  in 0 milliseconds
I0930 01:44:46.905482   47718 round_trippers.go:449] Response Headers:
I0930 01:44:46.905504   47718 cached_discovery.go:121] skipped caching discovery info due to Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
I0930 01:44:46.905556   47718 round_trippers.go:423] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.17.12 (linux/amd64) kubernetes/5ec4722" 'http://localhost:8080/api?timeout=32s'
I0930 01:44:46.905695   47718 round_trippers.go:443] GET http://localhost:8080/api?timeout=32s  in 0 milliseconds
I0930 01:44:46.905712   47718 round_trippers.go:449] Response Headers:
I0930 01:44:46.905734   47718 cached_discovery.go:121] skipped caching discovery info due to Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
I0930 01:44:46.905759   47718 helpers.go:221] Connection error: Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
F0930 01:44:46.905785   47718 helpers.go:114] The connection to the server localhost:8080 was refused - did you specify the right host or port?
kubectl配置视图
如下

apiVersion:v1 集群: -群集: 证书颁发机构数据:数据+省略 服务器:https://172.31.3.157:6443 姓名:kubernetes 上下文: -背景: 集群:kubernetes 用户:kubernetes管理员 姓名:kubernetes-admin@kubernetes 当前上下文:kubernetes-admin@kubernetes 种类:配置 首选项:{} 用户: -姓名:kubernetes管理员 用户: 客户端证书数据:已编辑 客户端密钥数据:已编辑 作为参考,工作
kubectl顶部节点
调试模式如下:, (日志太长,仅附加了标题)


“端口转发”命令显示转发端口80;您的故障日志显示无法连接到8080。谢谢,我不打算连接localhost:8080。有什么办法可以解决吗?故障日志是从哪里来的?是什么操作导致的?这是单节点配置吗?您运行群集的基础架构是什么?主机操作系统版本是什么?当您在
sudo
下运行时,您使用的是root用户的
/root/.kube/config
文件,而不是您自己的文件,这就是为什么会出现奇怪的错误。您通常会使用
负载平衡器
类型的服务配置Istio入口网关,因此通常可以从集群外部访问它;你能直接连接到它吗?
I0930 01:46:47.625764   49195 loader.go:375] Config loaded from file:  /home/ubuntu/.kube/config
I0930 01:46:47.641064   49195 round_trippers.go:423] curl -k -v -XGET  -H "User-Agent: kubectl/v1.17.12 (linux/amd64) kubernetes/5ec4722" -H "Accept: application/json, */*" 'https://172.31.3.157:6443/api?timeout=32s'
I0930 01:46:47.680091   49195 round_trippers.go:443] GET https://172.31.3.157:6443/api?timeout=32s 200 OK in 39 milliseconds
I0930 01:46:47.680116   49195 round_trippers.go:449] Response Headers:
I0930 01:46:47.680123   49195 round_trippers.go:452]     Cache-Control: no-cache, private
I0930 01:46:47.680128   49195 round_trippers.go:452]     Content-Type: application/json
I0930 01:46:47.680134   49195 round_trippers.go:452]     Content-Length: 135
I0930 01:46:47.680139   49195 round_trippers.go:452]     Date: Wed, 30 Sep 2020 01:46:47 GMT
I0930 01:46:47.680340   49195 request.go:1017] Response Body: {"kind":"APIVersions","versions":["v1"],"serverAddressByClientCIDRs":[{"clientCIDR":"0.0.0.0/0","serverAddress":"172.31.3.157:6443"}]}
I0930 01:46:47.680594   49195 round_trippers.go:423] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.17.12 (linux/amd64) kubernetes/5ec4722" 'https://172.31.3.157:6443/apis?timeout=32s'