• Kubernetes Submit Queue's avatar
    Merge pull request #57461 from danwinship/proxier-no-dummy-nat-rules · e6c2a5de
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue (batch tested with PRs 55637, 57461, 60268, 60290, 60210). 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>.
    
    Don't create no-op iptables rules for services with no endpoints
    
    Currently for all services we create `-t nat -A KUBE-SERVICES` rules that match the destination IPs (ClusterIP, ExternalIP, NodePort IPs, etc) and then jump to the appropriate `KUBE-SVC-XXXXXX` chain. But if the service has no endpoints then the `KUBE-SVC-XXXXXX` chain will be empty and so nothing happens except that we wasted time (a) forcing iptables-restore to parse the match rules, and (b) forcing the kernel to test matches that aren't going to have any effect.
    
    This PR gets rid of the match rules in this case. Which is to say, it changes things so that every incoming service packet is matched *either* by nat rules to rewrite it *or* by filter rules to ICMP reject it, but not both. (Actually, that's not quite true: there are no filter rules to reject Ingress-addressed packets, and I *think* that's a bug?)
    
    I also got rid of some comments that seemed redundant.
    
    The patch is mostly reindentation, so best viewed with `diff -w`.
    
    Partial fix for #56842 / Related to #56164 (which it conflicts with but I'll fix that after one or the other merges).
    
    **Release note**:
    ```release-note
    Removed some redundant rules created by the iptables proxier, to improve performance on systems with very many services.
    ```
    e6c2a5de
Name
Last commit
Last update
..
apis/kubeproxyconfig Loading commit data...
config Loading commit data...
healthcheck Loading commit data...
iptables Loading commit data...
ipvs Loading commit data...
metrics Loading commit data...
userspace Loading commit data...
util Loading commit data...
winkernel Loading commit data...
winuserspace Loading commit data...
BUILD Loading commit data...
OWNERS Loading commit data...
doc.go Loading commit data...
endpoints.go Loading commit data...
endpoints_test.go Loading commit data...
service.go Loading commit data...
service_test.go Loading commit data...
types.go Loading commit data...