微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何为“ kubectl port-forward”设置正确的端口奇怪地转到localhost:8080

如何解决如何为“ kubectl port-forward”设置正确的端口奇怪地转到localhost:8080

我通过kubeadm安装kubernetes,然后关闭并重新启动。 然后只有kubectl port-forward不起作用。

以下命令有效。

kubectl top nodes

但是kubectl端口转发失败。有什么建议吗? 似乎只有端口转发转到localhost: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 config view

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://172.31.3.157:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED

作为参考,下面是工作的kubectl top nodes调试模式, (日志太长,我只附加了标题

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'

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。