mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-26 12:46:06 +00:00
Merge pull request #96488 from basantsa1989/kproxy_cleanup
Kube-proxy cleanup: Changing FilterIncorrectIP/CIDR functions to MapIPsToIPFamily that returns a map
This commit is contained in:
@@ -294,10 +294,11 @@ func NewProxier(ipt utiliptables.Interface,
|
||||
ipFamily = v1.IPv6Protocol
|
||||
}
|
||||
|
||||
var incorrectAddresses []string
|
||||
nodePortAddresses, incorrectAddresses = utilproxy.FilterIncorrectCIDRVersion(nodePortAddresses, ipFamily)
|
||||
if len(incorrectAddresses) > 0 {
|
||||
klog.Warningf("NodePortAddresses of wrong family; %s", incorrectAddresses)
|
||||
ipFamilyMap := utilproxy.MapCIDRsByIPFamily(nodePortAddresses)
|
||||
nodePortAddresses = ipFamilyMap[ipFamily]
|
||||
// Log the IPs not matching the ipFamily
|
||||
if ips, ok := ipFamilyMap[utilproxy.OtherIPFamily(ipFamily)]; ok && len(ips) > 0 {
|
||||
klog.Warningf("IP Family: %s, NodePortAddresses of wrong family; %s", ipFamily, strings.Join(ips, ","))
|
||||
}
|
||||
|
||||
proxier := &Proxier{
|
||||
@@ -367,17 +368,17 @@ func NewDualStackProxier(
|
||||
nodePortAddresses []string,
|
||||
) (proxy.Provider, error) {
|
||||
// Create an ipv4 instance of the single-stack proxier
|
||||
nodePortAddresses4, nodePortAddresses6 := utilproxy.FilterIncorrectCIDRVersion(nodePortAddresses, v1.IPv4Protocol)
|
||||
ipFamilyMap := utilproxy.MapCIDRsByIPFamily(nodePortAddresses)
|
||||
ipv4Proxier, err := NewProxier(ipt[0], sysctl,
|
||||
exec, syncPeriod, minSyncPeriod, masqueradeAll, masqueradeBit, localDetectors[0], hostname,
|
||||
nodeIP[0], recorder, healthzServer, nodePortAddresses4)
|
||||
nodeIP[0], recorder, healthzServer, ipFamilyMap[v1.IPv4Protocol])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create ipv4 proxier: %v", err)
|
||||
}
|
||||
|
||||
ipv6Proxier, err := NewProxier(ipt[1], sysctl,
|
||||
exec, syncPeriod, minSyncPeriod, masqueradeAll, masqueradeBit, localDetectors[1], hostname,
|
||||
nodeIP[1], recorder, healthzServer, nodePortAddresses6)
|
||||
nodeIP[1], recorder, healthzServer, ipFamilyMap[v1.IPv6Protocol])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create ipv6 proxier: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user