Commit Graph

1841 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
724497cda4
Merge pull request #114094 from Nanfei-Chen/master
Modifies receiver names for struct FakeProxier to make them the same.
2023-01-22 16:30:09 -08:00
Dan Winship
463153fb7c Fix ContainsIPv4Loopback() to match its caller's behavior
ContainsIPv4Loopback() claimed that "::/0" contains IPv4 loopback IPs
(on the theory that listening on "::/0" will listen on "0.0.0.0/0" as
well and thus include IPv4 loopback). But its sole caller (the
iptables proxier) doesn't use listen() to accept connections, so this
theory was completely mistaken; if you passed, eg,
`--nodeport-addresses 192.168.0.0/0,::/0`, then it would not create
any rule that accepted nodeport connections on 127.0.0.1, but it would
nonetheless end up setting route_localnet=1 because
ContainsIPv4Loopback() claimed it needed to. Fix this.
2023-01-21 14:25:08 -05:00
Dan Winship
53b24f4ddf Improve GetNodeAddresses unit test
Add names to the tests and use t.Run() (rather than having them just
be numbered, with number 9 mistakenly being used twice thus throwing
off all the later numbers...)

Remove unnecessary FakeNetwork element from the testCases struct since
it's always the same. Remove the expectedErr value since a non-nil
error is expected if and only if the returned set is nil, and there's
no reason to test the exact text of the error message.

Fix weird IPv6 subnet sizes.

Change the dual-stack tests to (a) actually have dual-stack interface
addrs, and (b) use a routable IPv6 address, not just localhost (given
that we never actually want to use IPv6 localhost for nodeports).
2023-01-21 14:25:08 -05:00
Dan Winship
fe49e3933d Move GetNodeAddresses() and ContainsIPv4Loopback() into a new file
Both sound slightly generic, but implement semantics specific to the
handling of NodePort addresses.

(No changes other than moving code.)
2023-01-21 14:25:07 -05:00
Kubernetes Prow Robot
5e9fc39d17
Merge pull request #114878 from Nordix/ipvs-allow-any-sheduler
Ipvs: remove the scheduler validation
2023-01-17 11:18:46 -08:00
Kubernetes Prow Robot
7372e7e807
Merge pull request #114724 from tnqn/fix-lb-svc-delete-error
Do not log errors when ServiceHealthServer is closed normally
2023-01-11 10:31:45 -08:00
Hao Ruan
7f3de6e53a fix a typo in pkg/proxy/ipvs/proxier.go 2023-01-09 09:29:22 +08:00
Lars Ekman
c2bae4dfbd Ipvs: remove the scheduler validation 2023-01-06 19:42:13 +01:00
Kubernetes Prow Robot
fcaa32bd99
Merge pull request #114725 from danwinship/kube-proxy-startup-cleanup
(minor) kube-proxy startup cleanup
2023-01-05 13:57:59 -08:00
Kubernetes Prow Robot
d9af380f91
Merge pull request #114749 from danwinship/drop-endpointshandler
Drop unused EndpointsHandler / EndpointsConfig from pkg/proxy/config
2023-01-05 03:58:09 -08:00
Dan Winship
fe2b658ef5 Drop unused Endpoints-only tracking code in kube-proxy
This leaves the code in a somewhat messy state but it can be improved
further later.
2023-01-03 09:03:49 -05:00
Dan Winship
c78b057d85 Port TestUpdateEndpointsMap from Endpoints tracker to EndpointSlice
This is an ugly-but-simple rewrite (particularly involving having to
rewrite "single Endpoints with multiple Subsets" as "multiple
EndpointSlices"). Can be cleaned up more later...

The slice code sorts the results slightly differently from the old
code in two cases, and it was simpler to just reorder the expectations
rather than fixing the comparison code. But other than that, the
expected results are exactly the same as before.
2023-01-03 09:03:46 -05:00
Dan Winship
cc1847e6ee Port TestLastChangeTriggerTime from Endpoints tracker to EndpointSlice
This exposed a bug in the EndpointSlice tracking code, which is that
we didn't properly reset the "last change time" when a slice was
deleted. (This means kube-proxy would report an erroneous value in the
"endpoint programming time" metric if a service was added/updated,
then deleted before kube-proxy processed the add/update, then later
added again.)
2023-01-03 09:03:34 -05:00
Dan Winship
169604d906 Validate single-stack --nodeport-addresses sooner
In the dual-stack case, iptables.NewDualStackProxier and
ipvs.NewDualStackProxier filtered the nodeport addresses values by IP
family before creating the single-stack proxiers. But in the
single-stack case, the kube-proxy startup code just passed the value
to the single-stack proxiers without validation, so they had to
re-check it themselves. Fix that.
2023-01-03 09:01:45 -05:00
Dan Winship
e7ed7220eb Explicitly pass IP family to proxier
Rather than re-determining it from the iptables object in both proxies.
2023-01-03 09:01:45 -05:00
Dan Winship
2ea105df63 Drop unused EndpointsHandler / EndpointsConfig from pkg/proxy/config
(Also NoopEndpointSliceHandler since it's no longer possible for a
proxy implementation to no-op EndpointSlice handling.)
2023-01-01 16:57:27 -05:00
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
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