Can not telnet localhost port which is exposed by kube-proxy

11/5/2019

I have a k8s cluster, and there are some ports which are exposed by kube-proxy such as 31381 and 31382.

[root@rg1-ostack219 leo]# hostname -I | awk '{print $1}'
10.211.85.97
[root@rg1-ostack219 leo]# netstat -anp |grep " LISTEN "
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      21156/sshd
tcp        0      0 127.0.0.1:10009         0.0.0.0:*               LISTEN      90833/scribed
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      3006/master
tcp        0      0 0.0.0.0:16509           0.0.0.0:*               LISTEN      2207/libvirtd
tcp        0      0 127.0.0.1:33123         0.0.0.0:*               LISTEN      89258/kubelet
tcp        0      0 127.0.0.1:10248         0.0.0.0:*               LISTEN      89258/kubelet
tcp        0      0 0.0.0.0:52360           0.0.0.0:*               LISTEN      2464/hooagent
tcp        0      0 127.0.0.1:10249         0.0.0.0:*               LISTEN      64755/kube-proxy
tcp        0      0 0.0.0.0:6666            0.0.0.0:*               LISTEN      97587/ssh
tcp        0      0 127.0.0.1:10251         0.0.0.0:*               LISTEN      90172/kube-schedule
tcp        0      0 127.0.0.1:2379          0.0.0.0:*               LISTEN      90052/etcd
tcp        0      0 10.211.85.97:2379       0.0.0.0:*               LISTEN      90052/etcd
tcp        0      0 127.0.0.1:10252         0.0.0.0:*               LISTEN      89938/kube-controll
tcp        0      0 10.211.85.97:2380       0.0.0.0:*               LISTEN      90052/etcd
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1675/rpcbind
tcp6       1      0 :::31381                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::31413                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::31382                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::31830                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::22                   :::*                    LISTEN      21156/sshd
tcp6       0      0 :::32026                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::443                  :::*                    LISTEN      91307/traefik
tcp6       0      0 :::32541                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::31485                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::31390                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::31392                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::30692                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::31400                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::6666                 :::*                    LISTEN      97587/ssh
tcp6       0      0 :::10250                :::*                    LISTEN      89258/kubelet
tcp6       0      0 :::6443                 :::*                    LISTEN      89836/kube-apiserve
tcp6       0      0 :::9100                 :::*                    LISTEN      50266/node_exporter
tcp6       0      0 :::111                  :::*                    LISTEN      1675/rpcbind
tcp6       0      0 :::8080                 :::*                    LISTEN      91307/traefik
tcp6       0      0 :::80                   :::*                    LISTEN      91307/traefik
tcp6       0      0 :::10256                :::*                    LISTEN      64755/kube-proxy
tcp6       0      0 :::10257                :::*                    LISTEN      89938/kube-controll
tcp6       0      0 :::32116                :::*                    LISTEN      64755/kube-proxy
tcp6       1      0 :::31380                :::*                    LISTEN      64755/kube-proxy

The problem is When I run telnet 10.211.85.97 31381 and telnet 127.0.0.1 6443, everything is ok, but when I run telnet 127.0.0.1 31381, there is no any response.

-- leo
kubernetes
linux
telnet

1 Answer

11/5/2019

It doesn't listen on the same localhost the is connected to your hypervisor host machine. Each kube-proxy service proxy gets its own cluster IP that functions like a container would more or less, though with more iptables magic usually.

-- coderanger
Source: StackOverflow