kube-proxy: fix duplicate port opening
When nodePortAddresses is not specified for kube-proxy, it tried to open the node port for a NodePort service twice, triggered by IPv4ZeroCIDR and IPv6ZeroCIDR separately. The first attempt would succeed and the second one would always generate an error log like below: "listen tcp4 :30522: bind: address already in use" This patch fixes it by ensuring nodeAddresses of a proxier only contain the addresses for its IP family.
This commit is contained in:
@@ -1587,7 +1587,15 @@ COMMIT
|
||||
-A KUBE-SERVICES -m comment --comment "kubernetes service nodeports; NOTE: this must be the last rule in this chain" -m addrtype --dst-type LOCAL -j KUBE-NODEPORTS
|
||||
COMMIT
|
||||
`
|
||||
|
||||
assert.Equal(t, []*netutils.LocalPort{
|
||||
{
|
||||
Description: "nodePort for ns1/svc1:p80",
|
||||
IP: "",
|
||||
IPFamily: netutils.IPv4,
|
||||
Port: svcNodePort,
|
||||
Protocol: netutils.TCP,
|
||||
},
|
||||
}, fp.portMapper.(*fakePortOpener).openPorts)
|
||||
assertIPTablesRulesEqual(t, expected, fp.iptablesData.String())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user