set config.BindAddress to IPv4 address "127.0.0.1" if not specified

Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
This commit is contained in:
zouyee
2019-10-25 21:46:41 +08:00
parent a3560d3ad9
commit a3e0ac2951
4 changed files with 11 additions and 14 deletions

View File

@@ -26,7 +26,7 @@ import (
"net"
"strings"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
utilnet "k8s.io/apimachinery/pkg/util/net"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -137,7 +137,8 @@ func newProxyServer(
if nodeIP.IsUnspecified() {
nodeIP = utilnode.GetNodeIP(client, hostname)
if nodeIP == nil {
return nil, fmt.Errorf("unable to get node IP for hostname %s", hostname)
klog.V(0).Infof("can't determine this node's IP, assuming 127.0.0.1; if this is incorrect, please set the --bind-address flag")
nodeIP = net.ParseIP("127.0.0.1")
}
}
if proxyMode == proxyModeIPTables {