mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #83822 from zouyee/proxy-remove
set config.BindAddress to IPv4 address "127.0.0.1" if not specified
This commit is contained in:
commit
1732b435b3
@ -26,7 +26,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
utilnet "k8s.io/apimachinery/pkg/util/net"
|
utilnet "k8s.io/apimachinery/pkg/util/net"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
@ -137,7 +137,8 @@ func newProxyServer(
|
|||||||
if nodeIP.IsUnspecified() {
|
if nodeIP.IsUnspecified() {
|
||||||
nodeIP = utilnode.GetNodeIP(client, hostname)
|
nodeIP = utilnode.GetNodeIP(client, hostname)
|
||||||
if nodeIP == nil {
|
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 {
|
if proxyMode == proxyModeIPTables {
|
||||||
|
@ -18,6 +18,7 @@ package kubemark
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
@ -77,6 +78,11 @@ func NewHollowProxyOrDie(
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
if useRealProxier {
|
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.
|
// Real proxier with fake iptables, sysctl, etc underneath it.
|
||||||
//var err error
|
//var err error
|
||||||
proxier, err = iptables.NewProxier(
|
proxier, err = iptables.NewProxier(
|
||||||
@ -89,7 +95,7 @@ func NewHollowProxyOrDie(
|
|||||||
0,
|
0,
|
||||||
"10.0.0.0/8",
|
"10.0.0.0/8",
|
||||||
nodeName,
|
nodeName,
|
||||||
utilnode.GetNodeIP(client, nodeName),
|
nodeIP,
|
||||||
recorder,
|
recorder,
|
||||||
nil,
|
nil,
|
||||||
[]string{},
|
[]string{},
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
discovery "k8s.io/api/discovery/v1alpha1"
|
discovery "k8s.io/api/discovery/v1alpha1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
@ -279,11 +279,6 @@ func NewProxier(ipt utiliptables.Interface,
|
|||||||
masqueradeValue := 1 << uint(masqueradeBit)
|
masqueradeValue := 1 << uint(masqueradeBit)
|
||||||
masqueradeMark := fmt.Sprintf("%#08x/%#08x", masqueradeValue, masqueradeValue)
|
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 {
|
if len(clusterCIDR) == 0 {
|
||||||
klog.Warning("clusterCIDR not specified, unable to distinguish between internal and external traffic")
|
klog.Warning("clusterCIDR not specified, unable to distinguish between internal and external traffic")
|
||||||
} else if utilnet.IsIPv6CIDRString(clusterCIDR) != ipt.IsIpv6() {
|
} else if utilnet.IsIPv6CIDRString(clusterCIDR) != ipt.IsIpv6() {
|
||||||
|
@ -403,11 +403,6 @@ func NewProxier(ipt utiliptables.Interface,
|
|||||||
masqueradeValue := 1 << uint(masqueradeBit)
|
masqueradeValue := 1 << uint(masqueradeBit)
|
||||||
masqueradeMark := fmt.Sprintf("%#08x/%#08x", masqueradeValue, masqueradeValue)
|
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)
|
isIPv6 := utilnet.IsIPv6(nodeIP)
|
||||||
|
|
||||||
klog.V(2).Infof("nodeIP: %v, isIPv6: %v", nodeIP, isIPv6)
|
klog.V(2).Infof("nodeIP: %v, isIPv6: %v", nodeIP, isIPv6)
|
||||||
|
Loading…
Reference in New Issue
Block a user