mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 06:01:50 +00:00
Merge pull request #66489 from tanshanshan/todoclean
Automatic merge from submit-queue (batch tested with PRs 66489, 66728, 66739). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Reuse iptablesContainerPortalArgs, remove function iptablesContainerNodePortArgs **What this PR does / why we need it**: reuse iptablesContainerPortalArgs, remove function iptablesContainerNodePortArgs **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
@@ -708,7 +708,7 @@ func (proxier *Proxier) openNodePort(nodePort int, protocol api.Protocol, proxyI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle traffic from containers.
|
// Handle traffic from containers.
|
||||||
args := proxier.iptablesContainerNodePortArgs(nodePort, protocol, proxyIP, proxyPort, name)
|
args := proxier.iptablesContainerPortalArgs(nil, false, false, nodePort, protocol, proxyIP, proxyPort, name)
|
||||||
existed, err := proxier.iptables.EnsureRule(iptables.Append, iptables.TableNAT, iptablesContainerNodePortChain, args...)
|
existed, err := proxier.iptables.EnsureRule(iptables.Append, iptables.TableNAT, iptablesContainerNodePortChain, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Failed to install iptables %s rule for service %q", iptablesContainerNodePortChain, name)
|
glog.Errorf("Failed to install iptables %s rule for service %q", iptablesContainerNodePortChain, name)
|
||||||
@@ -811,7 +811,7 @@ func (proxier *Proxier) closeNodePort(nodePort int, protocol api.Protocol, proxy
|
|||||||
el := []error{}
|
el := []error{}
|
||||||
|
|
||||||
// Handle traffic from containers.
|
// Handle traffic from containers.
|
||||||
args := proxier.iptablesContainerNodePortArgs(nodePort, protocol, proxyIP, proxyPort, name)
|
args := proxier.iptablesContainerPortalArgs(nil, false, false, nodePort, protocol, proxyIP, proxyPort, name)
|
||||||
if err := proxier.iptables.DeleteRule(iptables.TableNAT, iptablesContainerNodePortChain, args...); err != nil {
|
if err := proxier.iptables.DeleteRule(iptables.TableNAT, iptablesContainerNodePortChain, args...); err != nil {
|
||||||
glog.Errorf("Failed to delete iptables %s rule for service %q", iptablesContainerNodePortChain, name)
|
glog.Errorf("Failed to delete iptables %s rule for service %q", iptablesContainerNodePortChain, name)
|
||||||
el = append(el, err)
|
el = append(el, err)
|
||||||
@@ -1061,23 +1061,6 @@ func (proxier *Proxier) iptablesHostPortalArgs(destIP net.IP, addDstLocalMatch b
|
|||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a slice of iptables args for a from-container public-port rule.
|
|
||||||
// See iptablesContainerPortalArgs
|
|
||||||
// TODO: Should we just reuse iptablesContainerPortalArgs?
|
|
||||||
func (proxier *Proxier) iptablesContainerNodePortArgs(nodePort int, protocol api.Protocol, proxyIP net.IP, proxyPort int, service proxy.ServicePortName) []string {
|
|
||||||
args := iptablesCommonPortalArgs(nil, false, false, nodePort, protocol, service)
|
|
||||||
|
|
||||||
if proxyIP.Equal(zeroIPv4) || proxyIP.Equal(zeroIPv6) {
|
|
||||||
// TODO: Can we REDIRECT with IPv6?
|
|
||||||
args = append(args, "-j", "REDIRECT", "--to-ports", fmt.Sprintf("%d", proxyPort))
|
|
||||||
} else {
|
|
||||||
// TODO: Can we DNAT with IPv6?
|
|
||||||
args = append(args, "-j", "DNAT", "--to-destination", net.JoinHostPort(proxyIP.String(), strconv.Itoa(proxyPort)))
|
|
||||||
}
|
|
||||||
|
|
||||||
return args
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build a slice of iptables args for a from-host public-port rule.
|
// Build a slice of iptables args for a from-host public-port rule.
|
||||||
// See iptablesHostPortalArgs
|
// See iptablesHostPortalArgs
|
||||||
// TODO: Should we just reuse iptablesHostPortalArgs?
|
// TODO: Should we just reuse iptablesHostPortalArgs?
|
||||||
|
Reference in New Issue
Block a user