mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-18 16:21:13 +00:00
fix localport open - iptables part changes
This commit is contained in:
parent
04634cb198
commit
b2f5c8e610
@ -960,12 +960,34 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
if svcInfo.NodePort != 0 {
|
if svcInfo.NodePort != 0 {
|
||||||
// Hold the local port open so no other process can open it
|
// Hold the local port open so no other process can open it
|
||||||
// (because the socket might open but it would never work).
|
// (because the socket might open but it would never work).
|
||||||
|
addresses, err := utilproxy.GetNodeAddresses(proxier.nodePortAddresses, proxier.networkInterfacer)
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("Failed to get node ip address matching nodeport cidr")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
lps := make([]utilproxy.LocalPort, 0)
|
||||||
|
for address := range addresses {
|
||||||
|
if utilproxy.IsZeroCIDR(address) {
|
||||||
lp := utilproxy.LocalPort{
|
lp := utilproxy.LocalPort{
|
||||||
Description: "nodePort for " + svcNameString,
|
Description: "nodePort for " + svcNameString,
|
||||||
IP: "",
|
IP: "",
|
||||||
Port: svcInfo.NodePort,
|
Port: svcInfo.NodePort,
|
||||||
Protocol: protocol,
|
Protocol: protocol,
|
||||||
}
|
}
|
||||||
|
lps = append(lps, lp)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
lp := utilproxy.LocalPort{
|
||||||
|
Description: "nodePort for " + svcNameString,
|
||||||
|
IP: address,
|
||||||
|
Port: svcInfo.NodePort,
|
||||||
|
Protocol: protocol,
|
||||||
|
}
|
||||||
|
lps = append(lps, lp)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, lp := range lps {
|
||||||
if proxier.portsMap[lp] != nil {
|
if proxier.portsMap[lp] != nil {
|
||||||
glog.V(4).Infof("Port %s was open before and is still needed", lp.String())
|
glog.V(4).Infof("Port %s was open before and is still needed", lp.String())
|
||||||
replacementPortsMap[lp] = proxier.portsMap[lp]
|
replacementPortsMap[lp] = proxier.portsMap[lp]
|
||||||
@ -987,6 +1009,7 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
}
|
}
|
||||||
replacementPortsMap[lp] = socket
|
replacementPortsMap[lp] = socket
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if hasEndpoints {
|
if hasEndpoints {
|
||||||
args = append(args[:0],
|
args = append(args[:0],
|
||||||
|
Loading…
Reference in New Issue
Block a user