Commit Graph

2294 Commits

Author SHA1 Message Date
Alessio Attilio
b5f44064ef pkg/proxy/nftables: fix kube-proxy crash with newer nftables versions
Fixes kube-proxy's nftables mode to work on systems with nft 1.1.3.
2026-03-17 08:15:03 -04:00
Prince Pereira
f00408bb42 Fix for preferred dualstack and required dualstack in winkernel proxier. 2026-01-21 05:41:34 +00:00
Prince Pereira
c70c4e578b kube-proxy/winkernel: fix stale RemoteEndpoints due to premature clearing of terminatedEndpoints map. 2025-11-06 07:57:28 +00:00
Kubernetes Prow Robot
9faf7038d3 Merge pull request #133527 from danwinship/automated-cherry-pick-of-#132680-origin-release-1.33
Automated cherry pick of #132680: Don't log irrelevant zone hints message on no endpoints
2025-10-08 22:53:00 -07:00
Kubernetes Prow Robot
28e39f67cc Merge pull request #133969 from aroradaman/automated-cherry-pick-of-#132456-upstream-release-1.33
Automated cherry pick of #132456: nftables short-circuit local traffic to external addresses
2025-09-26 06:24:18 -07:00
Kubernetes Prow Robot
2b83f33f8a Merge pull request #134032 from princepereira/automated-cherry-pick-of-#133953-upstream-release-1.33
Automated cherry pick of #133953: Fix ClusterIP load balancer disappearing when InternalTrafficPolicy: Local is set.
2025-09-26 02:48:19 -07:00
Jack Ma
54a33ecf45 fix: use iifname for input interface name matches
add tests to cover nftables; also fix NewDetectLocalByBridgeInterface
2025-09-17 09:58:31 -07:00
Prince Pereira
22e1fc1a7b Fix ClusterIP load balancer disappearing when InternalTrafficPolicy: Local is set. 2025-09-16 22:37:10 +05:30
Daman Arora
aded3faa53 nftables: remove filter-output-post-dnat chain
With filter-output chain already operating with priority
post DNAT, we can merge both the chains together.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-09-09 20:29:14 +05:30
Daman Arora
7109ea0fd6 update filter chains and priority
With this commit the filter-input, filter-forward, and filter-output base chains
are hooked with priority 0. For filtering before DNAT, filter-prerouting-pre-dnat
and filter-output-pre-dnat should be used which have a priority lower than DNAT
(-110)

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-09-09 20:29:14 +05:30
Miles Bryant
83d1055239 Don't log irrelevant zone hints message on no endpoints
Update pkg/proxy/topology.go

Co-authored-by: Dan Winship <danwinship@redhat.com>

Add unit test case
2025-08-14 09:58:16 -04:00
Prince Pereira
950bb3baf5 Fix for HNS local endpoint was being deleted instead of the remote endpoint. 2025-04-23 23:07:16 -07:00
Dan Winship
88f8e6697d Implement PreferSameNode traffic distribution in kube-proxy 2025-03-19 08:46:17 -04:00
Dan Winship
c85083589c Clarify hostname vs node name in kube-proxy
Various parts of kube-proxy passed around a "hostname", but it is
actually the name of the *node* kube-proxy is running on, which is not
100% guaranteed to be exactly the same as the hostname. Rename it
everywhere to make it clearer that (a) it is definitely safe to use
that name to refer to the Node, (b) it is not necessarily safe to use
that name with DNS, etc.
2025-03-19 08:46:15 -04:00
Dan Winship
ff640c3679 Minor updates to kube-proxy topology code
Clarify the comments around terminating endpoints.

Remove stale references to the ProxyTerminatingEndpoints feature gate
in the unit tests.
2025-03-19 08:39:13 -04:00
Kubernetes Prow Robot
fe27448ee4 Merge pull request #130833 from rzlink/master
Add Unit Tests for Windows DSR and Overlay Support
2025-03-18 12:45:56 -07:00
Dawei Wei
6186303580 Adding Unit tests for windows-dsr and overlay support 2025-03-17 14:36:39 -07:00
Gaurav Ghildiyal
9aeeb53095 Remove usage of TopologyAwareHints feature-gate from kube-proxy packages.
TopologyAwareHints feature-gate is GA'd and enabled by default since 1.33. Since
it is also locked-to-default, we can remove flag-usages in kube-proxy.

NOTE that as per
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/feature-gates.md#disablement-tests:
_"Disablement tests are only required to be preserved for components and
libraries that support compatibility version. Tests for node and kubelet are
unaffected by compatibility version."_
2025-03-14 12:06:40 -07:00
Kubernetes Prow Robot
caf541857f Merge pull request #130673 from gauravkghildiyal/kep-4444-ga
Promote ServiceTrafficDistribution feature-gate to GA and update docs with latest descriptions
2025-03-12 08:23:47 -07:00
Kubernetes Prow Robot
e9a3d99f37 Merge pull request #129826 from danwinship/iptables-constructors
fix up iptables construction, kubelet iptables startup messages
2025-03-11 01:17:45 -07:00
Gaurav Ghildiyal
4e317265c7 Remove usage of ServiceTrafficDistribution feature-gate from kube-proxy packages.
ServiceTrafficDistribution feature-gate is GA'd and enabled by default since
1.33. Since it is also locked-to-default, we can remove flag-usages in
kube-proxy.

NOTE that as per
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/feature-gates.md#disablement-tests:
_"Disablement tests are only required to be preserved for components and
libraries that support compatibility version. Tests for node and kubelet are
unaffected by compatibility version."_
2025-03-09 17:02:20 -07:00
Tim Hockin
e54719bb66 Use randfill, do API renames 2025-03-08 15:18:00 -08:00
Dan Winship
8c98dee1ed Add utiliptables.NewDualStack
Basically all callers want dual-stack-if-possible, so simplify that.

Also, tweak the startup-time checking in kubelet to treat "no iptables
support" as interesting but not an error.
2025-03-08 10:14:17 -05:00
Dan Winship
b62503dd66 Remove a dead error check in winkernel
The cmd/kube-proxy code never passes nil for the node IP any more.
2025-03-07 10:43:58 -05:00
Dan Winship
f001b3916d Remove a stale comment in metaproxier.go
(NodeHandler was implemented in metaProxier a long time ago.)
2025-03-07 10:43:56 -05:00
Dan Winship
303593cafe Fix some pkg/proxy comments
Remove a bunch of comments that are either inaccurate ("the proxier
can only be tested by e2e tests") or weirdly overspecific about
obvious details ("the proxier will not exit if an iptables call
fails").
2025-03-07 10:43:55 -05:00
Dan Winship
b5e9a8262e Remove exec arg from utilipset.New
Historically it took an exec argument so you could pass a FakeExec to
mock its behavior in unit tests, but it has a fake implementation now
that is much more useful for unit tests than trying to use the real
implementation with a fake exec. (The unit tests still use fake execs,
but they don't need to use a public constructor.) So remove the exec
args from the public constructors.
2025-03-07 10:43:52 -05:00
Dan Winship
36f5820ad1 Remove some unused proxy args/fields
Remove the utilexec.Interface args from the iptables/ipvs constructors
(which have been unused since the conntrack cleanup code was ported to
netlink).

Remove the EventRecorder fields from the iptables/ipvs Proxiers, which
have been unused since we removed the port-opener code in 2022.

Remove the strictARP field from the ipvs Proxier, which has apparently
always been unused (strictARP is only looked at at construct time).
2025-03-07 10:43:45 -05:00
Dan Winship
13f0449e4c Fix up kube-proxy import ordering/organization. 2025-03-07 10:43:43 -05:00
Kubernetes Prow Robot
80026570aa Merge pull request #130119 from npinaeva/nft-restart
[kube-proxy: nftables] Optimize kube-proxy restart time
2025-03-04 10:17:44 -08:00
Adrian Moisey
438d496555 Add test for ReconcileConntrackFlowsDeletedEntriesTotal metric 2025-03-02 15:58:40 +02:00
Kubernetes Prow Robot
ca22563752 Merge pull request #130484 from aojea/kube_proxy_reconciler_ports
conntrack reconciler must check the dst port
2025-03-01 14:54:55 -08:00
Antonio Ojea
e43de183cf conntrack reconciler must check the dst port
The conntrack reconciler maintains the consistency between the
conntrack table on each node and the desired state of Kubernetes UDP services.

A valid entry matches a service's ClusterIP, LoadBalancerIP, or ExternalIP and Service port,
or any ip matching a NodePort, and has a reverse source IP matching an active endpoint for
that service. Other entries are deleted.

Services without endpoints and traffic not handled by kube-proxy are ignored

Co-authored-by: Daman Arora <aroradaman@gmail.com>
2025-02-28 21:14:06 +00:00
Tim Hockin
c8111709e5 Add an error matcher, convert 2 tests
I fixed up the TestValidateEndpointsCreate path to show the matcher
instead of manual origin checking.

I picked TestValidateTopologySpreadConstraints because it was the last
failing test on my screen when I changed on of the commonly hard-coded
error strings. I fixed exactly those validation errors that were needed
to make this test pass.  Some of the Origin values can be debated.

The `field/testing.Matcher` interface allows tests to configure the
criteria by which they want to match expected and actual errors.  The
hope is that everyone will use Origin for Invalid errors.

There's some collateral impact for tests which use exact-comparisons and
don't expect origins.  These are all candidates for using the matcher.
2025-02-28 08:36:26 -08:00
Nadia Pinaeva
cc0faf086d [kube-proxy:nftables] Skip EP chain updates on startup.
Endpoint chain contents are fairly predictable from their name and
existing affinity sets. Skip endpoint chain updates, when we can be sure
that rules in that chain are still correct.

Add unit test to verify first transaction is optimized.
Change baseRules ordering to make it accepted by nft.ParseDump.

Signed-off-by: Nadia Pinaeva <npinaeva@redhat.com>
2025-02-27 10:07:22 +01:00
Ryota Sakamoto
f484ae5bcb Fix kernel version check condition in nftables proxier
Signed-off-by: Ryota Sakamoto <skmt@amazon.com>
2025-02-24 18:45:16 +00:00
Kubernetes Prow Robot
1b22629615 Merge pull request #130286 from marosset/windows-unit-tests-proxy-winkernel-tests
Fixing k8s.io/kubernetes/pkg/proxy/winkernel unit tests
2025-02-19 15:52:33 -08:00
Kubernetes Prow Robot
1aef26a7eb Merge pull request #130256 from adrianmoisey/netlink-without-tests
Add retries to some netlink calls - without tests
2025-02-19 15:52:26 -08:00
Kubernetes Prow Robot
9f8d5321f0 Merge pull request #130266 from princepereira/ppereira-winproxy-logformat
Introduced additional log formatting to windows kubeproxy.
2025-02-19 14:38:33 -08:00
Mark Rossetti
2b1b20b3b1 Fixing k8s.io/kubernetes/pkg/proxy/winkernel unit tests
Signed-off-by: Mark Rossetti <marosset@microsoft.com>
2025-02-19 11:49:53 -08:00
Prince Pereira
3d007532e0 Introduced additional log formatting to windows kubeproxy. 2025-02-19 01:44:39 -08:00
Adrian Moisey
faf6dc1313 Add retries to runner.List() 2025-02-19 08:29:06 +02:00
Adrian Moisey
b6f49d0728 Add retries to conntracker.ClearEntries()
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-02-19 08:29:06 +02:00
Adrian Moisey
90a42e0dc0 Add retries to conntracker.ListEntries()
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-02-19 08:29:05 +02:00
Nadia Pinaeva
7d5f3c5723 [kube-proxy:nftables] Read map/set elements on setup.
We used to flush and re-add all map/set elements on nftables
setup, but it is faster to read the existing elements and only
transact the diff.

Signed-off-by: Nadia Pinaeva <npinaeva@redhat.com>
2025-02-18 11:28:41 +01:00
Daman Arora
438df173e3 kube-proxy: metric to track entries deleted in conntrack reconciliation
kubeproxy_conntrack_reconciler_deleted_entries_total can be used
to track total entries deleted in conntrack reconciliation.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-02-17 00:06:20 +05:30
Daman Arora
bdd83038e8 kube-proxy: metric to track conntrack reconciliation latency
kube_proxy_conntrack_reconciler_sync_duration_seconds can be used
to track the latency of conntrack flow reconciliation.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-02-16 13:51:40 +05:30
Kubernetes Prow Robot
d7774fce9a Merge pull request #129653 from danwinship/nftables-ga
KEP-3866 nftables kube-proxy to GA
2025-02-13 08:42:20 -08:00
Dan Winship
83595f500a NFTablesProxyMode to GA 2025-02-13 10:27:14 -05:00
Daman Arora
6971779d0d pkg/proxy/conntrack: refactor log levels for conntrack cleanup
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-02-07 15:35:26 +05:30