Connect to self over hostPort in kubernetes?

11/22/2017

Our kubernetes deployment leverages a hostPort to enable other instances of our application running outside of the kubernetes cluster to be clustered together. The clustering feature requires that our application must be able to connect to itself using it's “public address” which is NODE_IP:HOST_PORT.

Our k8s cluster is using CNI (tried with both Flannel and Weave) and the portmap plugin to enable the HostPort feature. The host port feature works great with the exception that the pod cannot connect to itself using NODE_IP:HOST_PORT. NODE_IP:HOST_PORT works from other pods, the kubernetes host, and external hosts, but not from the pod itself that is exposing the hostPort. Instead the connection request hangs and eventually times out.

I thought this might be related to https://github.com/containernetworking/cni/issues/476 but I believe hairpin mode is enabled and I am able to connect fine from the pod to the pod's Service IP.

Should this work? Is there some config change that might enable this connectivity? I'm running kubernetes v1.8.3.

-- erics
kubernetes

0 Answers