2329 Commits

Author SHA1 Message Date
Dawei Wei
a806e069e2 Remove WinDSR feature gate unit test 2025-07-23 17:40:53 +00:00
Kubernetes Prow Robot
ce9ba81802 Merge pull request #133059 from danwinship/node-manager
kube-proxy node manager (take 2)
2025-07-21 20:36:27 -07:00
Dan Winship
facbb66142 Temporarily revert restart-on-node-IP-change behavior of proxy NodeManager 2025-07-21 17:00:45 -04:00
Daman Arora
e2d37f3cd7 kube-proxy: merge OnNodeAdd and OnNodeUpdate into OnNodeChange
For kube-proxy, node addition and node update is semantically
considered as similar event, we have exactly same handler
logic for these two events resulting in duplicate code and
unit tests.
This merges the `NodeHandler` interface methods OnNodeAdd and
OnNodeUpdate into OnNodeChange along with the implementation
of the interface.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-07-21 17:00:44 -04:00
Daman Arora
0dc51b16f9 kube-proxy: merge NodeEligibleHandler with NodeManager
ProxyHealthServer now consumes NodeManager to get the latest
updated node object for determining node eligibility.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
Co-authored-by: Dan Winship <danwinship@redhat.com>
2025-07-21 17:00:44 -04:00
Daman Arora
d4892fef76 kube-proxy: merge NodePodCIDRHandler with NodeManager
NodeManager, if configured with to watch for PodCIDR watch, watches
for changes in PodCIDRs and crashes kube-proxy if a change is
detected in PodCIDRs.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
Co-authored-by: Dan Winship <danwinship@redhat.com>
2025-07-21 17:00:44 -04:00
Daman Arora
373fb487f6 kube-proxy: add NodeManager to manage life-cycle based on NodeIPs
NodeManager initialises node informers, waits for cache sync and polls for
node object to retrieve NodeIPs, handle node events and crashes kube-proxy
when change in NodeIPs is detected.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
Co-authored-by: Dan Winship <danwinship@redhat.com>
2025-07-21 17:00:44 -04:00
Daman Arora
d21ca8674c kube-proxy: add NodeTopologyConfig for tracking topology labels
This simplifies how the proxier receives update for change in node
labels. Instead of passing the complete Node object we just pass
the proxy relevant topology labels extracted from the complete list
of labels, and the downstream event handlers will only be notified
when there are changes in topology labels.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-07-21 17:00:44 -04:00
Dan Winship
8acda3631f Belatedly add tests of proxy NodeConfig and ServiceCIDRConfig 2025-07-21 17:00:42 -04:00
roc
bfa33b18a0 fix(kube-proxy) avoid add zero-masked loadBalancerSourceRanges to ipset
Signed-off-by: roc <roc@imroc.cc>
2025-07-18 09:55:39 +08:00
Daman Arora
bc5088cbf3 Revert "Kube proxy node manager" 2025-07-15 19:34:05 +05:30
Daman Arora
46e2c22fd7 kube-proxy: merge OnNodeAdd and OnNodeUpdate into OnNodeChange
For kube-proxy, node addition and node update is semantically
considered as similar event, we have exactly same handler
logic for these two events resulting in duplicate code and
unit tests.
This merges the `NodeHandler` interface methods OnNodeAdd and
OnNodeUpdate into OnNodeChange along with the implementation
of the interface.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-07-11 23:06:44 +05:30
Daman Arora
fa9e466945 kube-proxy: merge NodeEligibleHandler with NodeManager
ProxyHealthServer now consumes NodeManager to get the latest
updated node object for determining node eligibility.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-07-11 23:06:44 +05:30
Daman Arora
c6735d9b3b kube-proxy: merge NodePodCIDRHandler with NodeManager
NodeManager, if configured with to watch for PodCIDR watch, watches
for changes in PodCIDRs and crashes kube-proxy if a change is
detected in PodCIDRs.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-07-11 23:06:44 +05:30
Daman Arora
c43104cbea kube-proxy: add NodeManager to manage life-cycle based on NodeIPs
NodeManager initialises node informers, waits for cache sync and polls for
node object to retrieve NodeIPs, handle node events and crashes kube-proxy
when change in NodeIPs is detected.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-07-11 21:48:52 +05:30
Daman Arora
af7abde0e5 kube-proxy: add NodeTopologyConfig for tracking topology labels
This simplifies how the proxier receives update for change in node
labels. Instead of passing the complete Node object we just pass
the proxy relevant topology labels extracted from the complete list
of labels, and the downstream event handlers will only be notified
when there are changes in topology labels.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-07-11 21:05:19 +05:30
Kubernetes Prow Robot
d269d10bfc Merge pull request #132647 from princepereira/ppereira-incorrect-internalport
Ensure Loadbalancer internal port is set to container port from endpointslice if the targetPort is not specified in service info creation.
2025-07-10 18:41:27 -07:00
Kubernetes Prow Robot
9538d53353 Merge pull request #132456 from aroradaman/nftables-etp-fix
nftables short-circuit local traffic to external addresses
2025-07-09 17:53:27 -07:00
Miles Bryant
1cec0acebf Short circuit CategorizeEndpoints when there are no endpoints
PR feedback
2025-07-08 11:14:08 +01:00
Miles Bryant
1ac5f661ed 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-07-04 11:10:55 +01:00
Kubernetes Prow Robot
c3b06a5366 Merge pull request #131615 from danwinship/proxy-bfr
update BoundedFrequencyRunner for kube-proxy
2025-07-01 09:21:24 -07:00
Antonio Ojea
459188ce25 Port BoundedFrequencyRunner from flowcontrol.RateLimiter to clock.Clock
Co-authored-by: Dan Winship <danwinship@redhat.com>
2025-07-01 08:54:14 -04:00
Dan Winship
eae17c21b0 Change how BoundedFrequencyRunner retries work
Rather than having a RetryAfter function, do a retry (at a fixed
interval) if the work function returns an error.

Co-authored-by: Antonio Ojea <aojea@google.com>
2025-07-01 08:54:14 -04:00
Dan Winship
c16ee887ef Remove burst syncs from BoundedFrequencyRunner
Burst syncs are theoretically useful for dealing with a single change
that results in multiple Run() calls (eg, a Service and EndpointSlice
both changing), but 2 isn't enough to cover all cases, and a better
way of dealing with this problem is to just use a smaller
minSyncPeriod.

Co-authored-by: Antonio Ojea <aojea@google.com>
2025-07-01 08:54:14 -04:00
Dan Winship
0298e04ea0 Updates to BoundedFrequencyRunner
- Use structured logging.
- Use t.Helper() in unit tests.
- Improve some comments.
- Remove an unnecessary check/panic.

Co-authored-by: Antonio Ojea <aojea@google.com>
2025-07-01 08:54:14 -04:00
Antonio Ojea
6da9d363f3 Copy BoundedFrequencyRunner to kube-proxy 2025-07-01 08:53:54 -04:00
Prince Pereira
d4e49b2eed Ensure Loadbalancer internal port is set to container port from endpointslice if the targetPort is not specified in service info creation. 2025-07-01 02:25:37 -07:00
Daman Arora
7e3945808d 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-06-23 18:12:13 +05:30
Daman Arora
91f2256b34 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-06-23 18:12:13 +05:30
Daman Arora
af89044a78 conntrack: clean stale entries on endpoint port change
With this commit, the conntrack reconciler clears the stales
entries when endpoints change port without changing IP.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-06-23 00:37:28 +05:30
Daman Arora
512563e7b0 pkg/proxy/conntrack: refactor
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-06-18 14:22:26 +05:30
Kubernetes Prow Robot
43bb11b5c1 Merge pull request #131534 from aroradaman/kube-proxy-ipt-init-error-2
kube-proxy: log iptables errors in platformCheckSupported
2025-06-06 21:08:38 -07:00
Daman Arora
858b88bcee kube-proxy: log ipt errors during platformCheckSupported
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-06-07 01:14:33 +05:30
Kubernetes Prow Robot
2f94274c88 Merge pull request #131562 from logica0419/kube-proxy-string-concat
Add missing space in string concatenation (kube-proxy)
2025-05-27 13:36:22 -07:00
Kubernetes Prow Robot
ef66667c8e Merge pull request #131243 from danwinship/kube-proxy-cleanup
Improve `kube-proxy --cleanup` / cleanup on kube-proxy mode switch
2025-05-06 09:29:13 -07:00
Kubernetes Prow Robot
0b8133816b Merge pull request #131477 from pohly/golangci-lint@v2
golangci-lint v2
2025-05-02 23:03:55 -07:00
Matthieu MOREL
4adb58565c chore: bump golangci-lint to v2
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-02 12:51:02 +02:00
logica0419
43a0da5880 add missing space in string concatenation (kube-proxy) 2025-04-30 23:35:25 +09:00
Daman Arora
c7a870135a nftables: cleanup service chain checks
A packet can traverse the service-xxxx chains by matching on either
service-ips or service-nodeports verdict map. We masquerade off-cluster
traffic to ClusterIP (when masqueradeAll = false) by adding a rule in
service-xxxx which checks if destination IP is ClusterIP, port and
protocol matches with service specs and source IP doesn't belong to
PodCIDR and masquerade on match.

If the packet reaches the service chain by match on service-ips map,
then ClusterIP, port and protocol are already matching service specs.
If it comes via external-xxxx chain then the destination IP will
never be ClusterIP. Therefore, we can simplify the masquerade
off-cluster traffic to ClusterIP check by simply matching on
destination ip and source ip.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-04-27 01:05:45 +05:30
Kubernetes Prow Robot
b9d2c1b043 Merge pull request #131138 from princepereira/ppereira-130963-endpointcreation
Fix for HNS local endpoint was being deleted instead of the remote endpoint.
2025-04-23 16:00:11 -07:00
Kubernetes Prow Robot
13dd327f0d Merge pull request #130687 from tomma-a/master
Made the unsupportedError msg more readable
2025-04-23 13:31:21 -07:00
Dan Winship
f9c1876b45 Make proxy CleanupLeftovers methods quieter
To make switching to/from nftables easier, kube-proxy runs iptables
and ipvs cleanup when starting in nftables mode, and runs nftables
cleanup when starting in iptables or ipvs mode. But there's no
guarantee that the node actually supports the mode we're trying to
clean up, so don't log errors if it doesn't.
2025-04-10 14:58:37 -04:00
Dan Winship
b61ca041b4 Add some missing cleanup to "kube-proxy --cleanup"
iptables and ipvs were both leaving KUBE-MARK-MASQ behind (even though
the corresponding KUBE-POSTROUTING rule to actually do the masquerade
got deleted).

iptables was failing to clean up its KUBE-PROXY-FIREWALL chain (the
cleanup rules never got updated when that was split out of
KUBE-FIREWALL), and also not cleaning up its canary chain.
2025-04-10 14:58:35 -04:00
Dan Winship
30f1bcadea Add a unit test for iptables.CleanupLeftovers, improve ipvs test 2025-04-10 09:05:23 -04:00
Dan Winship
94530dad7b Move iptables/ipvs/ipset interface creation into CleanupLeftovers
This also fixes it so that ipvs.CleanupLeftovers only deletes
ipvs/ipset stuff once, rather than first deleting all of it on behalf
of the IPv4 Proxier and then no-op "deleting" it all again on behalf
of the IPv6 Proxier.
2025-04-10 09:03:25 -04:00
Prince Pereira
cc42846187 Fix for HNS local endpoint was being deleted instead of the remote endpoint. 2025-04-08 07:10:13 -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