无法访问localhost

时间:2019-11-13 15:55:23

标签: kubernetes kubectl

我无法在localhost:nodePort上访问kubernetes服务,但可以在127.0.0.1:nodePort上访问它。我也可以通过masterip:nodePort

这样的浏览器访问服务

以下输出

[root@k8s-master ~]# kubectl get services
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP        4h26m
nginx        NodePort    10.109.106.21   <none>        80:30893/TCP   7m24s
[root@k8s-master ~]# curl -I 127.0.0.1:30893
HTTP/1.1 200 OK
Server: nginx/1.17.5
Date: Wed, 13 Nov 2019 15:48:44 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 22 Oct 2019 14:30:00 GMT
Connection: keep-alive
ETag: "5daf1268-264"
Accept-Ranges: bytes

[root@k8s-master ~]# curl -I localhost:30893
^C
[root@k8s-master ~]# ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.094 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.077 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.069 ms
^C
--- localhost ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.069/0.080/0.094/0.010 ms

现在我担心如果localhost无法正常工作,是因为我的网络没有针对k8集群正确配置 如何解决此问题。

1 个答案:

答案 0 :(得分:1)

有一个已报告的旧问题here,似乎与您的问题有关。

因此,可能与IPv6有关,一种解决方案是在<AdditionalDependencies>lz32.lib;wsock32.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> 命令的每次执行中添加--ipv4选项,或者通过禁用主机应用永久解决方案完全是IPv6。