mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
fix localport open - ipvs part changes
This commit is contained in:
parent
b2f5c8e610
commit
ac1cd3dcb4
@ -985,27 +985,50 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if svcInfo.NodePort != 0 {
|
if svcInfo.NodePort != 0 {
|
||||||
lp := utilproxy.LocalPort{
|
addresses, err := utilproxy.GetNodeAddresses(proxier.nodePortAddresses, proxier.networkInterfacer)
|
||||||
Description: "nodePort for " + svcNameString,
|
if err != nil {
|
||||||
IP: "",
|
glog.Errorf("Failed to get node ip address matching nodeport cidr")
|
||||||
Port: svcInfo.NodePort,
|
continue
|
||||||
Protocol: protocol,
|
|
||||||
}
|
}
|
||||||
if proxier.portsMap[lp] != nil {
|
|
||||||
glog.V(4).Infof("Port %s was open before and is still needed", lp.String())
|
lps := make([]utilproxy.LocalPort, 0)
|
||||||
replacementPortsMap[lp] = proxier.portsMap[lp]
|
for address := range addresses {
|
||||||
} else {
|
if utilproxy.IsZeroCIDR(address) {
|
||||||
socket, err := proxier.portMapper.OpenLocalPort(&lp)
|
lp := utilproxy.LocalPort{
|
||||||
if err != nil {
|
Description: "nodePort for " + svcNameString,
|
||||||
glog.Errorf("can't open %s, skipping this nodePort: %v", lp.String(), err)
|
IP: "",
|
||||||
continue
|
Port: svcInfo.NodePort,
|
||||||
|
Protocol: protocol,
|
||||||
|
}
|
||||||
|
lps = append(lps, lp)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if lp.Protocol == "udp" {
|
lp := utilproxy.LocalPort{
|
||||||
isIPv6 := utilnet.IsIPv6(svcInfo.ClusterIP)
|
Description: "nodePort for " + svcNameString,
|
||||||
conntrack.ClearEntriesForPort(proxier.exec, lp.Port, isIPv6, clientv1.ProtocolUDP)
|
IP: address,
|
||||||
|
Port: svcInfo.NodePort,
|
||||||
|
Protocol: protocol,
|
||||||
}
|
}
|
||||||
replacementPortsMap[lp] = socket
|
lps = append(lps, lp)
|
||||||
} // We're holding the port, so it's OK to install ipvs rules.
|
}
|
||||||
|
|
||||||
|
for _, lp := range lps {
|
||||||
|
if proxier.portsMap[lp] != nil {
|
||||||
|
glog.V(4).Infof("Port %s was open before and is still needed", lp.String())
|
||||||
|
replacementPortsMap[lp] = proxier.portsMap[lp]
|
||||||
|
} else {
|
||||||
|
socket, err := proxier.portMapper.OpenLocalPort(&lp)
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("can't open %s, skipping this nodePort: %v", lp.String(), err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if lp.Protocol == "udp" {
|
||||||
|
isIPv6 := utilnet.IsIPv6(svcInfo.ClusterIP)
|
||||||
|
conntrack.ClearEntriesForPort(proxier.exec, lp.Port, isIPv6, clientv1.ProtocolUDP)
|
||||||
|
}
|
||||||
|
replacementPortsMap[lp] = socket
|
||||||
|
} // We're holding the port, so it's OK to install ipvs rules.
|
||||||
|
}
|
||||||
|
|
||||||
// Nodeports need SNAT, unless they're local.
|
// Nodeports need SNAT, unless they're local.
|
||||||
// ipset call
|
// ipset call
|
||||||
@ -1038,11 +1061,6 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
|
|
||||||
// Build ipvs kernel routes for each node ip address
|
// Build ipvs kernel routes for each node ip address
|
||||||
nodeIPs := make([]net.IP, 0)
|
nodeIPs := make([]net.IP, 0)
|
||||||
addresses, err := utilproxy.GetNodeAddresses(proxier.nodePortAddresses, proxier.networkInterfacer)
|
|
||||||
if err != nil {
|
|
||||||
glog.Errorf("Failed to get node ip address matching nodeport cidr")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for address := range addresses {
|
for address := range addresses {
|
||||||
if !utilproxy.IsZeroCIDR(address) {
|
if !utilproxy.IsZeroCIDR(address) {
|
||||||
nodeIPs = append(nodeIPs, net.ParseIP(address))
|
nodeIPs = append(nodeIPs, net.ParseIP(address))
|
||||||
|
Loading…
Reference in New Issue
Block a user