I am not able to access kubernetes service on localhost:nodePort but can access the same on 127.0.0.1:nodePort. Also i can access service from browser like masterip:nodePort
below is output
[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
Now i am worried that if localhost do not work.Is it that my network is not properly configured for k8 cluster How to fix this issue.
There is an old reported issue here that seems to be related to your problem.
According to that, it may be something to do with IPv6 and a solution is to add the --ipv4
option to each execution of the curl
command, or apply a permanent solution for the host by disabling IPv6 altogether.