mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
fix review
This commit is contained in:
parent
63bc96e1b0
commit
dc768c87c3
@ -401,10 +401,7 @@ func NewProxyServer(config *componentconfig.KubeProxyConfiguration, cleanupAndEx
|
||||
glog.V(0).Info("Using iptables Proxier.")
|
||||
var nodeIP net.IP
|
||||
if config.BindAddress != "0.0.0.0" {
|
||||
nodeIP := net.ParseIP(config.BindAddress)
|
||||
if local := isLocalIP(nodeIP); !local {
|
||||
return nil, fmt.Errorf("invalid bind-address: %v, it must be a local IP", config.BindAddress)
|
||||
}
|
||||
nodeIP = net.ParseIP(config.BindAddress)
|
||||
} else {
|
||||
nodeIP = getNodeIP(client, hostname)
|
||||
}
|
||||
@ -708,20 +705,3 @@ func getNodeIP(client clientset.Interface, hostname string) net.IP {
|
||||
}
|
||||
return nodeIP
|
||||
}
|
||||
|
||||
func isLocalIP(ip net.IP) bool {
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
for i := range addrs {
|
||||
intfIP, _, err := net.ParseCIDR(addrs[i].String())
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if ip.Equal(intfIP) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user