Commit Graph

1879 Commits

Author SHA1 Message Date
Dan Winship
886c4b0cf2 Drop Endpoints-tracking-specific TestEndpointsToEndpointsMap
TestEndpointsToEndpointsMap tested code that only ran when using
Endpoints tracking rather than EndpointSlice tracking--which is to
say, never, any more. (TestEndpointsMapFromESC in
endpointslicecache_test.go is an equivalent EndpointSlice test.)
2022-12-31 12:03:23 -05:00
Dan Winship
df7e4a9432 Belatedly port pkg/proxy/config Endpoints unit tests to EndpointSlice 2022-12-30 19:51:35 -05:00
Dan Winship
0ea0295965 Duplicate the "anti-martian-packet" rule in kube-proxy
This rule was mistakenly added to kubelet even though it only applies
to kube-proxy's traffic. We do not want to remove it from kubelet yet
because other components may be depending on it for security, but we
should make kube-proxy output its own rule rather than depending on
kubelet.
2022-12-29 16:24:58 -05:00
Dan Winship
305641bd4c Add iptablesKubeletJumpChains to iptables proxier
Some of the chains kube-proxy creates are also created by kubelet; we
need to ensure that those chains exist but we should not delete them
in CleanupLeftovers().
2022-12-29 16:24:58 -05:00
Dan Winship
37a8a2bdaf fix indentation of iptables dumps in some test cases
(Especially, use tabs rather than spaces.)
2022-12-29 16:24:58 -05:00
Dan Winship
1870c4cdd7 Add a comment-only rule to the end of KUBE-FW-* chains
With the removal of the "-j KUBE-MARK-DROP" rules, the firewall chains
end rather ambiguously. Add a comment-only rule explaining what will
happen.
2022-12-29 16:24:58 -05:00
Quan Tian
a5790d5caa Do not log errors when ServiceHealthServer is closed normally
Server.Serve() always returns a non-nil error. If it exits because the
http server is closed, it will return ErrServerClosed. To differentiate
the error, this patch changes to close the http server instead of the
listener when the Service is deleted. Closing http server automatically
closes the listener, there is no need to cache the listeners any more.

Signed-off-by: Quan Tian <qtian@vmware.com>
2022-12-29 17:11:29 +08:00
Lars Ekman
5ff705fd77 proxy/ipvs: Describe and handle a bug in moby/ipvs
Handle https://github.com/moby/ipvs/issues/27
A work-around was already in place, but a segv would occur
when the bug is fixed. That will not happen now.
2022-12-24 10:21:27 +01:00
Lars Ekman
68d78c89ec use netutils.ParseIPSloppy 2022-12-23 14:19:28 +01:00
Lars Ekman
dc86bdc3aa Handle an empty scheduler ("") 2022-12-23 13:23:02 +01:00
Lars Ekman
4adc687275 Fixed typo 2022-12-23 11:13:55 +01:00
Lars Ekman
cf214d0738 Clean-up un-used code 2022-12-23 10:54:51 +01:00
Lars Ekman
3bd3759424 gofmt 2022-12-23 10:14:47 +01:00
Lars Ekman
b169f22eb8 Updates after rewiew
To update the scheduler without node reboot now works.
The address for the probe VS is now 198.51.100.0 which is
reseved for documentation, please see rfc5737. The comment
about this is extended.
2022-12-23 10:11:15 +01:00
Lars Ekman
cd15ca0548 proxy/ipvs: Check that a dummy virtual server can be added
This tests both ipvs and the configured scheduler
2022-12-22 20:36:53 +01:00
Lars Ekman
4f02671b23 proxy/ipvs: Remove kernel module tests
To check kernel modules is a bad way to check functionality.
This commit just removes the checks and makes it possible to
use a statically linked kernel.

Minimal updates to unit-tests are made.
2022-12-22 17:13:41 +01:00
Nanfei Chen
3333d5195f Modifies receiver names for struct FakeProxier to make them the same.
Signed-off-by: Nanfei Chen <chennanfei@yeah.net>
2022-12-21 08:34:31 +08:00
Jordan Liggitt
78cb3862f1
Fix indentation/spacing in comments to render correctly in godoc 2022-12-17 23:27:38 -05:00
Kubernetes Prow Robot
53906cbe89
Merge pull request #114360 from dengyufeng2206/120802pull
Reduce redundant conversions
2022-12-16 11:06:09 -08:00
Kubernetes Prow Robot
d1879644a6
Merge pull request #113463 from wzshiming/clean/ioutil-ipvs
Replace the ioutil by the os and io for the pkg/proxy/ipvs
2022-12-16 11:05:58 -08:00
Dan Winship
c6cc056675 Replace iptables-proxy-specific SCTP e2e test with a unit test
We had a test that creating a Service with an SCTP port would create
an iptables rule with "-p sctp" in it, which let us test that
kube-proxy was doing vaguely the right thing with SCTP even if the e2e
environment didn't have SCTP support. But this would really make much
more sense as a unit test.
2022-12-13 16:21:12 -05:00
Prince Pereira
9abe8d9210 Windows Kube-Proxy implementation for internal traffic policy. 2022-12-13 14:26:10 +05:30
Prince Pereira
f132215ac1 Creating Ingress IP loadbalancer alone when all the endpoints are terminating. KEP1669 2022-12-13 12:46:58 +05:30
Kubernetes Prow Robot
923ee203f3
Merge pull request #110991 from thockin/svc-typenames-starTrafficPolicyType
Svc typenames star traffic policy type
2022-12-12 18:47:33 -08:00
Kubernetes Prow Robot
0e19bbb916
Merge pull request #113742 from princepereira/ppereira-kubeproxy-flags
Add a flag to HNS Load Balancer policy to hint HNS about the VIP being an External IP
2022-12-12 04:23:33 -08:00
Tim Hockin
dd0a50336e
ServiceInternalTrafficPolicyType: s/Type//
Rename ServiceInternalTrafficPolicyType => ServiceInternalTrafficPolicy
2022-12-11 13:48:31 -08:00
Tim Hockin
d0e2b06850
ServiceExternalTrafficPolicyType: s/Type//
Rename ServiceExternalTrafficPolicyType => ServiceExternalTrafficPolicy
2022-12-11 13:48:27 -08:00
dengyufeng2206
ba6afe213a Reduce redundant conversions 2022-12-08 15:21:24 +08:00
Prince Pereira
afbb21638c Introducing LoadbalancerPortMapping flags for VipExternalIP 2022-12-07 12:30:51 +05:30
Dan Winship
bfa4948bb6 Don't re-run EnsureChain/EnsureRules on partial syncs
We currently invoke /sbin/iptables 24 times on each syncProxyRules
before calling iptables-restore. Since even trivial iptables
invocations are slow on hosts with lots of iptables rules, this adds a
lot of time to each sync. Since these checks are expected to be a
no-op 99% of the time, skip them on partial syncs.
2022-11-29 09:42:49 -05:00
cyclinder
4aff0dba0d
kube-proxy ipatbles: update log message 2022-11-04 10:07:15 +08:00
Kubernetes Prow Robot
d86c013b0d
Merge pull request #108250 from cyclinder/add_flag_in_proxy
kube-proxy:  add a flag  to  disable nodePortOnLocalhost
2022-11-03 17:10:13 -07:00
Andy Voltz
29f4862ed8 Promote ServiceInternalTrafficPolicy to GA 2022-11-03 13:17:03 -04:00
Kubernetes Prow Robot
86a6ace994
Merge pull request #113277 from manav014/master
Cleanup: kube-proxy internal naming
2022-11-02 18:21:05 -07:00
Kubernetes Prow Robot
b60b0c74c9
Merge pull request #113521 from daschott/user/daschott/winkernel-stale-vips
resolve winkernel proxier treating stale VIPs as valid
2022-11-02 16:29:24 -07:00
Manav Agarwal
3320e50e24 If applied, this commit will refactor variable names in kube-proxy 2022-11-03 03:45:57 +05:30
cyclinder
bef2070031
kube-proxy: add a flag to disables the allowing NodePort services to be accessed via localhost 2022-11-02 16:17:52 +08:00
Kubernetes Prow Robot
3edbebe348
Merge pull request #110268 from danwinship/minimize-iptables-changes
minimize iptables-restore input
2022-11-01 18:06:46 -07:00
daschott
7b6e4e4d8b added retries to winkernel proxy rules deletion 2022-11-01 16:42:07 -07:00
daschott
dc2fc1045d added backend hashing to winkernel proxier 2022-10-31 21:57:34 -07:00
Kubernetes Prow Robot
4c657e5014
Merge pull request #110403 from claudiubelu/unittests-3
unittests: Fixes unit tests for Windows (part 3)
2022-10-31 15:52:44 -07:00
Shiming Zhang
1c8d3226a9 Replace the ioutil by the os and io for the pkg/proxy/ipvs 2022-10-31 16:29:19 +08:00
Claudiu Belu
9f95b7b18c unittests: Fixes unit tests for Windows (part 3)
Currently, there are some unit tests that are failing on Windows due to
various reasons:

- paths not properly joined (filepath.Join should be used).
- Proxy Mode IPVS not supported on Windows.
- DeadlineExceeded can occur when trying to read data from an UDP
  socket. This can be used to detect whether the port was closed or not.
- In Windows, with long file name support enabled, file names can have
  up to 32,767 characters. In this case, the error
  windows.ERROR_FILENAME_EXCED_RANGE will be encountered instead.
- files not closed, which means that they cannot be removed / renamed.
- time.Now() is not as precise on Windows, which means that 2
  consecutive calls may return the same timestamp.
- path.Base() will return the same path. filepath.Base() should be used
  instead.
- path.Join() will always join the paths with a / instead of the OS
  specific separator. filepath.Join() should be used instead.
2022-10-21 19:25:48 +03:00
Han Kang
958845e0be migrate usage of to for static analysis
Change-Id: I33753683b48a8a57b2548b0d3caeb6050ddc5c95
2022-10-18 17:01:32 -07:00
Antonio Ojea
a38b9363ec kube-proxy handle node PodCIDR changs
Kube/proxy, in NodeCIDR local detector mode, uses the node.Spec.PodCIDRs
field to build the Services iptables rules.

The Node object depends on the kubelet, but if kube-proxy runs as a
static pods or as a standalone binary, it is not possible to guarantee
that the values obtained at bootsrap are valid, causing traffic outages.

Kube-proxy has to react on node changes to avoid this problems, it
simply restarts if detect that the node PodCIDRs have changed.

In case that the Node has been deleted, kube-proxy will only log an
error and keep working, since it may break graceful shutdowns of the
node.
2022-10-18 19:25:40 +00:00
Antonio Ojea
cf532a8e36 kube-proxy: gate topology correctly 2022-10-18 19:25:40 +00:00
Claudiu Belu
af77381e01 unit tests: Skip Windows-unrelated tests on Windows
Some of the unit tests cannot pass on Windows due to various reasons:

- fsnotify does not have a Windows implementation.
- Proxy Mode IPVS not supported on Windows.
- Seccomp not supported on Windows.
- VolumeMode=Block is not supported on Windows.
- iSCSI volumes are mounted differently on Windows, and iscsiadm is a
  Linux utility.
2022-10-18 12:43:07 +03:00
daschott
fba80c8b89 added daschott to winkernel owners 2022-10-17 16:28:11 -07:00
Amim Knabben
c0d323f1f6 Fixing words in the comment 2022-10-15 15:54:41 -03:00
Kubernetes Prow Robot
6705015101
Merge pull request #112133 from knabben/remove-kproxy-userspace
Remove kube-proxy userspace modes
2022-10-14 17:31:06 -07:00
DingShujie
e1f0b85334 Dismiss connects to localhost early in the service chain
Signed-off-by: DingShujie <dingshujie@huawei.com>
2022-10-11 13:57:35 +08:00
Amim Knabben
7df6c02288 Remove Linux and Windows Kube-proxy Userspace mode 2022-10-05 16:59:02 -03:00
daschott
5bbf421841 Fix winkernel proxier setting the wrong HNS loadbalancer ID for ingress IP 2022-10-03 13:23:56 -07:00
Dan Winship
818de5a545 proxy/iptables: Add metric for partial sync failures, add test 2022-09-26 16:31:42 -04:00
Dan Winship
ab326d2f4e proxy/iptables: Don't rewrite chains that haven't changed
iptables-restore requires that if you change any rule in a chain, you
have to rewrite the entire chain. But if you avoid mentioning a chain
at all, it will leave it untouched. Take advantage of this by not
rewriting the SVC, SVL, EXT, FW, and SEP chains for services that have
not changed since the last sync, which should drastically cut down on
the size of each iptables-restore in large clusters.
2022-09-26 16:30:42 -04:00
Quan Tian
8a73e79777 Fix outdated code comments of proxierHealthServer
Signed-off-by: Quan Tian <qtian@vmware.com>
2022-09-21 23:21:19 +08:00
Kubernetes Prow Robot
e8e20ce563
Merge pull request #112451 from aojea/proxy_logging
kube-proxy use debug log level for Service cache operations
2022-09-19 14:21:45 -07:00
Kubernetes Prow Robot
918f84cd90
Merge pull request #112463 from Nordix/fix-ipvs-filter
Corrects target in the KUBE-IPVS-FILTER chain
2022-09-15 02:45:22 -07:00
Lars Ekman
639b9bca5d Corrects target in the KUBE-IPVS-FILTER chain
The target was "ACCEPT" which disabled any other check like
loadBalancerSourceRanges in the KUBE-PROXY-FIREWALL chain.
The target is now "RETURN".
2022-09-15 07:49:12 +02:00
Antonio Ojea
b84a5faaae kube-proxy use debug log level for cache operations
Level 4 is mean for debug operations.
The default level use to be level 2, on clusters with a lot of
Services this means that the kube-proxy will generate a lot of
noise on the logs, with the performance penalty associated to
it.
2022-09-14 17:57:08 +02:00
JunYang
fc6b421d97 cleanup useless check about CIDR 2022-09-14 11:43:35 +08:00
kerthcet
2b7373f336 kube-proxy: code optimization
Signed-off-by: kerthcet <kerthcet@gmail.com>
2022-09-04 19:34:22 +08:00
Kubernetes Prow Robot
9924814270
Merge pull request #108460 from Nordix/issue-72236
Prevent host access on VIP addresses in proxy-mode=ipvs
2022-09-01 12:59:18 -07:00
Sanskar Jaiswal
8b5f263cd3 add tests for initialSync usage in syncEndpoint
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2022-08-27 07:42:21 +00:00
Sanskar Jaiswal
b670656a09 update ipvs proxier to update realserver weights at startup
Update the IPVS proxier to have a bool `initialSync` which is set to
true when a new proxier is initialized and then set to false on all
syncs. This lets us run startup-only logic, which subsequently lets us
update the realserver only when needed and avoiding any expensive
operations.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2022-08-27 07:42:07 +00:00
Dan Winship
c437b15441 proxy/iptables: make part of the unit test sanity-checking optional 2022-08-24 09:02:48 -04:00
Kubernetes Prow Robot
da112dda68
Merge pull request #111806 from danwinship/kube-proxy-no-mode-fallback
remove kube-proxy mode fallback
2022-08-24 05:52:03 -07:00
Kubernetes Prow Robot
ef25013252
Merge pull request #111842 from ialidzhikov/cleanup/pkg-proxy
pkg/proxy: Replace deprecated func usage from the `k8s.io/utils/pointer` pkg
2022-08-23 20:08:08 -07:00
Kubernetes Prow Robot
9efbe6eb9b
Merge pull request #111379 from muyangren2/describe_err
wrong description
2022-08-23 16:05:17 -07:00
Dan Winship
1609017f2b kube-proxy: remove ipvs-to-iptables fallback
If the user passes "--proxy-mode ipvs", and it is not possible to use
IPVS, then error out rather than falling back to iptables.

There was never any good reason to be doing fallback; this was
presumably erroneously added to parallel the iptables-to-userspace
fallback (which only existed because we had wanted iptables to be the
default but not all systems could support it).

In particular, if the user passed configuration options for ipvs, then
they presumably *didn't* pass configuration options for iptables, and
so even if the iptables proxy is able to run, it is likely to be
misconfigured.
2022-08-16 09:30:08 -04:00
Dan Winship
9f69a3a9d4 kube-proxy: remove iptables-to-userspace fallback
Back when iptables was first made the default, there were
theoretically some users who wouldn't have been able to support it due
to having an old /sbin/iptables. But kube-proxy no longer does the
things that didn't work with old iptables, and we removed that check a
long time ago. There is also a check for a new-enough kernel version,
but it's checking for a feature which was added in kernel 3.6, and no
one could possibly be running Kubernetes with a kernel that old. So
the fallback code now never actually falls back, so it should just be
removed.
2022-08-16 09:21:34 -04:00
ialidzhikov
f2bc2ed2da pkg/proxy: Replace deprecated func usage from the k8s.io/utils/pointer pkg 2022-08-14 18:27:33 +03:00
Kubernetes Prow Robot
e16ac34361
Merge pull request #110289 from danwinship/kep-3178-source-ranges-drop
Don't use KUBE-MARK-DROP for LoadBalancerSourceRanges
2022-07-28 10:21:10 -07:00
Dan Winship
f65fbc877b proxy/iptables: remove last references to KUBE-MARK-DROP 2022-07-28 09:03:49 -04:00
Dan Winship
9313188909 proxy/iptables: Don't use KUBE-MARK-DROP for LoadBalancerSourceRanges 2022-07-28 09:03:46 -04:00
Kubernetes Prow Robot
4e5711829c
Merge pull request #111228 from Abirdcfly/220716
clean unreachable code
2022-07-27 11:35:00 -07:00
Kubernetes Prow Robot
ce433f87b4
Merge pull request #110266 from danwinship/minimize-prep-reorg
iptables proxy reorg in preparation for minimizing iptables-restore
2022-07-27 04:06:30 -07:00
Davanum Srinivas
a9593d634c
Generate and format files
- Run hack/update-codegen.sh
- Run hack/update-generated-device-plugin.sh
- Run hack/update-generated-protobuf.sh
- Run hack/update-generated-runtime.sh
- Run hack/update-generated-swagger-docs.sh
- Run hack/update-openapi-spec.sh
- Run hack/update-gofmt.sh

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-07-26 13:14:05 -04:00
muyangren2
9b29c930a2 wrong description 2022-07-25 13:41:59 +08:00
Kubernetes Prow Robot
7d72ccf9a8
Merge pull request #110957 from papagalu/kp_remove_hnsv1
kube-proxy: windows: Removed hnsV1
2022-07-20 04:02:38 -07:00
BinacsLee
f1c9a70b47 cleanup: simplify the function implementation of IPSet 2022-07-20 10:13:57 +08:00
Abirdcfly
f71718d644 clean Unreachable code
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2022-07-19 20:42:09 +08:00
Kubernetes Prow Robot
a521af7007
Merge pull request #111219 from dcbw/proxy-sync-on-node-events
proxy: queue syncs on node events rather than syncing immediately
2022-07-19 05:34:18 -07:00
Kubernetes Prow Robot
8af2c50201
Merge pull request #110762 from pandaamanda/windows_default_proxy
kube-proxy: kernelspace mode is announced to be default for windows
2022-07-18 11:45:15 -07:00
Dan Williams
f197509879 proxy: queue syncs on node events rather than syncing immediately
The proxies watch node labels for topology changes, but node labels
can change in bursts especially in larger clusters. This causes
pressure on all proxies because they can't filter the events, since
the topology could match on any label.

Change node event handling to queue the request rather than immediately
syncing. The sync runner can already handle short bursts which shouldn't
change behavior for most cases.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2022-07-18 09:21:52 -05:00
pandaamanda
fbe934da21 kube-proxy: kernelspace mode is announced to be default for windows 2022-07-18 01:04:56 +00:00
Dan Winship
367f18c49b proxy/iptables: move firewall chain setup
Part of reorganizing the syncProxyRules loop to do:
  1. figure out what chains are needed, mark them in activeNATChains
  2. write servicePort jump rules to KUBE-SERVICES/KUBE-NODEPORTS
  3. write servicePort-specific chains (SVC, SVL, EXT, FW, SEP)

This moves the FW chain creation to the end (rather than having it in
the middle of adding the jump rules for the LB IPs).
2022-07-09 07:08:42 -04:00
Dan Winship
2030591ce7 proxy/iptables: move internal traffic setup code
Part of reorganizing the syncProxyRules loop to do:
  1. figure out what chains are needed, mark them in activeNATChains
  2. write servicePort jump rules to KUBE-SERVICES/KUBE-NODEPORTS
  3. write servicePort-specific chains (SVC, SVL, EXT, FW, SEP)

This fixes the jump rules for internal traffic. Previously we were
handling "jumping from kubeServices to internalTrafficChain" and
"adding masquerade rules to internalTrafficChain" in the same place.
2022-07-09 07:07:48 -04:00
Dan Winship
00f789cd8d proxy/iptables: move EXT chain rule creation to the end
Part of reorganizing the syncProxyRules loop to do:
  1. figure out what chains are needed, mark them in activeNATChains
  2. write servicePort jump rules to KUBE-SERVICES/KUBE-NODEPORTS
  3. write servicePort-specific chains (SVC, SVL, EXT, FW, SEP)

This fixes the handling of the EXT chain.
2022-07-09 07:07:47 -04:00
Dan Winship
8906ab390e proxy/iptables: reorganize cluster/local chain creation
Part of reorganizing the syncProxyRules loop to do:
  1. figure out what chains are needed, mark them in activeNATChains
  2. write servicePort jump rules to KUBE-SERVICES/KUBE-NODEPORTS
  3. write servicePort-specific chains (SVC, SVL, EXT, FW, SEP)

This fixes the handling of the SVC and SVL chains. We were already
filling them in at the end of the loop; this fixes it to create them
at the bottom of the loop as well.
2022-07-09 07:05:05 -04:00
Dan Winship
da14a12fe5 proxy/iptables: move endpoint chain rule creation to the end
Part of reorganizing the syncProxyRules loop to do:
  1. figure out what chains are needed, mark them in activeNATChains
  2. write servicePort jump rules to KUBE-SERVICES/KUBE-NODEPORTS
  3. write servicePort-specific chains (SVC, SVL, EXT, FW, SEP)

This fixes the handling of the endpoint chains. Previously they were
handled entirely at the top of the loop. Now we record which ones are
in use at the top but don't create them and fill them in until the
bottom.
2022-07-09 06:51:47 -04:00
Dan Winship
8a5801996b proxy/iptables: belatedly simplify local traffic policy metrics
We figure out early on whether we're going to end up outputting no
endpoints, so update the metrics then.

(Also remove a redundant feature gate check; svcInfo already checks
the ServiceInternalTrafficPolicy feature gate itself and so
svcInfo.InternalPolicyLocal() will always return false if the gate is
not enabled.)
2022-07-09 06:50:16 -04:00
Dimitrie Mititelu
09ca06e875 kube-proxy: windows: Removed hnsV1
hnsV1 not supported anymore

Signed-off-by: Dimitrie Mititelu <dmititelu@cloudbasesolutions.com>
2022-07-05 22:24:23 +03:00
Dan Winship
95705350d5 proxy/iptables: Don't use KUBE-MARK-DROP for "no local endpoints"
Rather than marking packets to be dropped in the "nat" table and then
dropping them from the "filter" table later, just use rules in
"filter" to drop the packets we don't like directly.
2022-06-29 16:37:24 -04:00
Dan Winship
283218bd4c proxy/iptables: update TestTracePackets
Re-sync the rules from TestOverallIPTablesRulesWithMultipleServices to
make sure we're testing all the right kinds of rules. Remove a
duplicate copy of the KUBE-MARK-MASQ and KUBE-POSTROUTING rules.

Update the "REJECT" test to use the new svc6 from
TestOverallIPTablesRulesWithMultipleServices. (Previously it had used
a modified version of TOIPTRWMS's svc3.)
2022-06-29 16:33:13 -04:00
Dan Winship
59b7f969e8 proxy/iptables: fix up TestOverallIPTablesRulesWithMultipleServices
svc2b was using the same ClusterIP as svc3; change it and rename the
service to svc5 to make everything clearer.

Move the test of LoadBalancerSourceRanges from svc2 to svc5, so that
svc2 tests the rules for dropping packets due to
externalTrafficPolicy, and svc5 tests the rules for dropping packets
due to LoadBalancerSourceRanges, rather than having them both mixed
together in svc2.

Add svc6 with no endpoints.
2022-06-29 16:33:13 -04:00
Kubernetes Prow Robot
f045fb688f
Merge pull request #110334 from danwinship/iptables-fewer-saves
only clean up iptables chains periodically in large clusters
2022-06-29 09:48:06 -07:00
Dan Winship
7d3ba837f5 proxy/iptables: only clean up chains periodically in large clusters
"iptables-save" takes several seconds to run on machines with lots of
iptables rules, and we only use its result to figure out which chains
are no longer referenced by any rules. While it makes things less
confusing if we delete unused chains immediately, it's not actually
_necessary_ since they never get called during packet processing. So
in large clusters, make it so we only clean up chains periodically
rather than on every sync.
2022-06-29 11:14:38 -04:00
Dan Winship
1cd461bd24 proxy/iptables: abstract the "endpointChainsNumberThreshold" a bit
Turn this into a generic "large cluster mode" that determines whether
we optimize for performance or debuggability.
2022-06-29 11:14:38 -04:00
Dan Winship
c12da17838 proxy/iptables: Add a unit test with multiple resyncs 2022-06-29 11:14:38 -04:00