Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #83822: set config.BindAddress to IPv4 address "127.0.0.1" if not #84391

Merged
merged 1 commit into from Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/kube-proxy/app/server_others.go
Expand Up @@ -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"
Expand Down Expand Up @@ -142,7 +142,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 {
Expand Down
8 changes: 7 additions & 1 deletion pkg/kubemark/hollow_proxy.go
Expand Up @@ -18,6 +18,7 @@ package kubemark

import (
"fmt"
"net"
"time"

v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -77,6 +78,11 @@ func NewHollowProxyOrDie(
var err error

if useRealProxier {
nodeIP := utilnode.GetNodeIP(client, nodeName)
if nodeIP == nil {
klog.V(0).Infof("can't determine this node's IP, assuming 127.0.0.1")
nodeIP = net.ParseIP("127.0.0.1")
}
// Real proxier with fake iptables, sysctl, etc underneath it.
//var err error
proxier, err = iptables.NewProxier(
Expand All @@ -89,7 +95,7 @@ func NewHollowProxyOrDie(
0,
"10.0.0.0/8",
nodeName,
utilnode.GetNodeIP(client, nodeName),
nodeIP,
recorder,
nil,
[]string{},
Expand Down
7 changes: 1 addition & 6 deletions pkg/proxy/iptables/proxier.go
Expand Up @@ -32,7 +32,7 @@ import (
"sync/atomic"
"time"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
discovery "k8s.io/api/discovery/v1alpha1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -278,11 +278,6 @@ func NewProxier(ipt utiliptables.Interface,
masqueradeValue := 1 << uint(masqueradeBit)
masqueradeMark := fmt.Sprintf("%#08x/%#08x", masqueradeValue, masqueradeValue)

if nodeIP == nil {
klog.Warning("invalid nodeIP, initializing kube-proxy with 127.0.0.1 as nodeIP")
nodeIP = net.ParseIP("127.0.0.1")
}

if len(clusterCIDR) == 0 {
klog.Warning("clusterCIDR not specified, unable to distinguish between internal and external traffic")
} else if utilnet.IsIPv6CIDRString(clusterCIDR) != ipt.IsIpv6() {
Expand Down
5 changes: 0 additions & 5 deletions pkg/proxy/ipvs/proxier.go
Expand Up @@ -401,11 +401,6 @@ func NewProxier(ipt utiliptables.Interface,
masqueradeValue := 1 << uint(masqueradeBit)
masqueradeMark := fmt.Sprintf("%#08x/%#08x", masqueradeValue, masqueradeValue)

if nodeIP == nil {
klog.Warningf("invalid nodeIP, initializing kube-proxy with 127.0.0.1 as nodeIP")
nodeIP = net.ParseIP("127.0.0.1")
}

isIPv6 := utilnet.IsIPv6(nodeIP)

klog.V(2).Infof("nodeIP: %v, isIPv6: %v", nodeIP, isIPv6)
Expand Down