2276 Commits

Author SHA1 Message Date
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
Kubernetes Prow Robot
45d0fddaf1 Merge pull request #128971 from aojea/servicecidr_ga
KEP-1880 Multiple Service CIDRs: Graduate to GA
2025-01-22 11:12:44 -08:00
Kubernetes Prow Robot
3a4c2a0bbb Merge pull request #129271 from aroradaman/dual_stack_healthz
Dual stack healthz server
2025-01-20 07:32:42 -08:00
Antonio Ojea
e340a07ccf update kube-proxy 2025-01-20 13:01:53 +00:00
Dan Winship
cba6300414 Document nftables kube-proxy's "public API" 2025-01-15 15:53:51 -05:00
Daman Arora
271b8cf1c1 kube-proxy healthz handler ip family aware
Signed-off-by: Daman Arora <aroradaman@gmail.com>
Co-authored-by: Antonio Ojea <aojea@google.com>
2025-01-15 23:41:08 +05:30
olderTaoist
561c1d235a full sync per one hour with BFR 2025-01-14 09:24:38 +08:00
Daman Arora
3274dc40ed pkg/proxy/healthcheck: consolidate IsHealthy and isHealthy
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-01-11 15:20:31 +05:30
Daman Arora
1c1fc73616 pkg/proxy/healthcheck: enhance testing
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-01-11 15:20:31 +05:30
Daman Arora
64aac665fd pkg/proxy/healthcheck: bug fix for last updated time
The lastUpdated time returned by healthz call should be the latest
lastUpdated time among the proxiers. Prior to this commit, if proxy
is unhealthy, the returned lastUpdated time was lastUpdated time
of the unhealthy proxier.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-01-10 21:28:39 +05:30
Daman Arora
0645f0e50e pkg/proxy/healthcheck: file rename
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-01-08 17:40:42 +05:30
Daman Arora
d6c575532a pkg/proxy/healthcheck: rename 'proxier' to 'proxy'
KubeProxy operates with a single health server and two proxies,
one for each IP family. The use of the term 'proxier' in the
types and functions within pkg/proxy/healthcheck can be
misleading, as it may suggest the existence of two health
servers, one for each IP family.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-01-08 17:26:47 +05:30
changmin
19aef482fa fix incorrect variable reference in handleUpdateEndpointSlice 2024-12-17 15:06:04 +08:00
Dan Winship
f5969adb14 Clean up NewServiceChangeTracker/NewEndpointsChangeTracker args
Remove the now-unused event recorders, and put the remaining args into
a sensible order, and consistent between the two.
2024-12-14 12:12:42 -05:00
Dan Winship
79d1c078bb Make change trackers just ignore the "wrong" IP family
Dual-stack clusters exist; ServiceChangeTracker does not need to log
messages (even at V(4)) when it sees dual-stack Services, and
EndpointsChangeTracker does not need to emit Events(!) when it sees
EndpointSlices of the wrong AddressType.

(Though in most cases the EndpointsChangeTracker Events would not get
emitted anyway, since the MetaProxier would ensure that only the v4
tracker saw v4 slices, and only the v6 tracker saw v6 slices.)

Also remove a nil check labeled "This should never happen" which, in
fact, we know *didn't* happen, since the function has already
dereferenced the value before it checking it against nil.
2024-12-14 12:12:35 -05:00
Dan Winship
2c348bf186 Use a constructor properly in change tracker unit tests
newFakeProxier was inlining the details of NewEndpointsChangeTracker
so it could override trackerStartTime, but it would be better and more
future-proof to just call NewEndpointsChangeTracker normally and then
edit that one field.

(Also remove an unused FakeProxier field.)
2024-12-14 12:12:31 -05:00
Nadia Pinaeva
90e64a57c6 kube-proxy,nftables: add debug logging for failed transaction.
Use a rate limiter to avoid large output with a high rate.

Signed-off-by: Nadia Pinaeva <n.m.pinaeva@gmail.com>
2024-12-13 15:53:19 +01:00
Antonio Ojea
f93e6f3d3a kube-proxy implement dual stack metrics
Signed-off-by: Daman Arora <aroradaman@gmail.com>
Co-authored-by: Antonio Ojea <aojea@google.com>
2024-12-12 16:13:30 +05:30
Kubernetes Prow Robot
e8615e2712 Merge pull request #129054 from pohly/remove-import-name
remove import doc comments
2024-12-12 09:58:35 +01:00