mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #78662 from andrewsykim/77523-follow-up
iptables proxier: fix comments for LB IP traffic from local address
This commit is contained in:
commit
64262049c5
@ -1220,16 +1220,6 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// For LBs with externalTrafficPolicy=Local, we need to re-route any local traffic to the service chain masqueraded.
|
|
||||||
// Masqueraded traffic in this scenario is okay since source IP preservation only applies to external traffic anyways.
|
|
||||||
args = append(args[:0], "-A", string(svcXlbChain))
|
|
||||||
writeLine(proxier.natRules, append(args,
|
|
||||||
"-m", "comment", "--comment", fmt.Sprintf(`"masquerade LOCAL traffic for %s LB IP"`, svcNameString),
|
|
||||||
"-m", "addrtype", "--src-type", "LOCAL", "-j", string(KubeMarkMasqChain))...)
|
|
||||||
writeLine(proxier.natRules, append(args,
|
|
||||||
"-m", "comment", "--comment", fmt.Sprintf(`"route LOCAL traffic for %s LB IP to service chain"`, svcNameString),
|
|
||||||
"-m", "addrtype", "--src-type", "LOCAL", "-j", string(svcChain))...)
|
|
||||||
|
|
||||||
// First rule in the chain redirects all pod -> external VIP traffic to the
|
// First rule in the chain redirects all pod -> external VIP traffic to the
|
||||||
// Service's ClusterIP instead. This happens whether or not we have local
|
// Service's ClusterIP instead. This happens whether or not we have local
|
||||||
// endpoints; only if clusterCIDR is specified
|
// endpoints; only if clusterCIDR is specified
|
||||||
@ -1244,6 +1234,17 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
writeLine(proxier.natRules, args...)
|
writeLine(proxier.natRules, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Next, redirect all src-type=LOCAL -> LB IP to the service chain for externalTrafficPolicy=Local
|
||||||
|
// This allows traffic originating from the host to be redirected to the service correctly,
|
||||||
|
// otherwise traffic to LB IPs are dropped if there are no local endpoints.
|
||||||
|
args = append(args[:0], "-A", string(svcXlbChain))
|
||||||
|
writeLine(proxier.natRules, append(args,
|
||||||
|
"-m", "comment", "--comment", fmt.Sprintf(`"masquerade LOCAL traffic for %s LB IP"`, svcNameString),
|
||||||
|
"-m", "addrtype", "--src-type", "LOCAL", "-j", string(KubeMarkMasqChain))...)
|
||||||
|
writeLine(proxier.natRules, append(args,
|
||||||
|
"-m", "comment", "--comment", fmt.Sprintf(`"route LOCAL traffic for %s LB IP to service chain"`, svcNameString),
|
||||||
|
"-m", "addrtype", "--src-type", "LOCAL", "-j", string(svcChain))...)
|
||||||
|
|
||||||
numLocalEndpoints := len(localEndpointChains)
|
numLocalEndpoints := len(localEndpointChains)
|
||||||
if numLocalEndpoints == 0 {
|
if numLocalEndpoints == 0 {
|
||||||
// Blackhole all traffic since there are no local endpoints
|
// Blackhole all traffic since there are no local endpoints
|
||||||
|
Loading…
Reference in New Issue
Block a user