Commit Graph

2187 Commits

Author SHA1 Message Date
galal-hussein
612a2274b9 Ignore nfacct init error in kube-proxy
Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
2025-04-23 13:20:06 -03:00
Dan Winship
b84713348c Fix deleted UDP endpoint detection 2024-10-02 07:08:21 -04:00
Will Daly
f520ede814 kube-proxy: initialization wait for service and endpoint handlers synced
Ensure kube-proxy waits for the services/endpointslices informer
caches to be synced *and* all pre-sync events delivered before
setting isInitialized=true. Otherwise, in clusters with many services,
some services may be missing from svcPortMap when kube-proxy starts
(e.g. during daemonset rollout). This can cause kube-proxy to temporarily
remove service DNAT rules and then skip cleanup of UDP conntrack entries
to a service VIP.

Resolves: https://github.com/kubernetes/kubernetes/issues/126468
2024-08-14 09:02:23 -07:00
Davanum Srinivas
4fc6d8daf5 [kube-proxy] add log verbosity to endpoint topology hint loop - Take 2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-08-02 22:28:51 -04:00
Dr. Stefan Schimanski
c7a1fa432a Call non-blocking informerFactory.Start synchronously to avoid races
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
2024-07-27 18:13:09 +02:00
Daman Arora
5359098c14 kube-proxy: internal config: fuzz cidr values for unit tests
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-07-25 19:20:24 +05:30
Kubernetes Prow Robot
6834a1ef3d Merge pull request #126293 from aroradaman/kube-proxy-refactor-internal-config
Kube proxy refactor internal config
2024-07-23 11:02:46 -07:00
Nadia Pinaeva
2ec3929134 [kube-proxy:nftables] Add partial sync unit test.
Signed-off-by: Nadia Pinaeva <n.m.pinaeva@gmail.com>
2024-07-23 17:32:30 +02:00
Nadia Pinaeva
3ccf5b8a55 [kube-proxy:nftables] Add partialSync mode to only transact changed
objects.
Change the order of operations to stop current iteration if no changes
to the service chains are needed.
Bump syncProxy frequency to 1 hour.
In a test kind cluster creation of 10K services, 2 endpoints each,
takes ~25m before the fix and ~9min after. Maximum memory usage
during creation is ~650MiB and 260MiB respectively.
Another important metric is the time it takes to create 1 new service
when 10K svc already exist. It used to take ~8m before the fix,
with partialSync it takes ~141ms.

Signed-off-by: Nadia Pinaeva <n.m.pinaeva@gmail.com>
2024-07-23 17:32:30 +02:00
Nadia Pinaeva
dc13e42f56 [kube-proxy:nftables] cleanup: remove unused parameter and fix typo.
Signed-off-by: Nadia Pinaeva <n.m.pinaeva@gmail.com>
2024-07-23 17:32:29 +02:00
Daman Arora
3d589bd18a kube-proxy: internal config: remove PortRange
Remove PortRange for internal configuration of kube-proxy
adhering to the v1alpha2 version specifications as detailed in
https://kep.k8s.io/784.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-07-23 19:56:23 +05:30
Daman Arora
c57e1156f5 kube-proxy: internal config: refactor ClusterCIDR
Refactor ClusterCIDR for internal configuration of kube-proxy
adhering to the v1alpha2 version specifications as detailed in
https://kep.k8s.io/784.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-07-23 19:45:29 +05:30
Daman Arora
380adb93cc kube-proxy: internal config: consolidate SyncPeriod and MinSyncPeriod
Consolidate SyncPeriod and MinSyncPeriod for internal configuration
of kube-proxy adhering to the v1alpha2 version specifications as
detailed in https://kep.k8s.io/784.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-07-23 19:34:40 +05:30
Dan Winship
30bc1b59d7 Add unit tests to validate "bad IP/CIDR" handling in kube-proxy
Also, fix the handling of bad EndpointSlice IPs!
2024-07-18 10:55:13 -04:00
Dan Winship
f762e5c8de Remove an unnecessary comment in nftables output
(It's redundant with the chain name.)
2024-07-18 10:54:30 -04:00
Dan Winship
11f55eae96 Reduce some duplication in nftables unit tests 2024-07-18 10:53:36 -04:00
Daman Arora
6c10c97c3c kube-proxy: internal config: add Linux section
Introduce Linux section for internal configuration of kube-proxy
adhering to the v1alpha2 version specifications as detailed in
https://kep.k8s.io/784.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-07-16 19:20:48 +05:30
Daman Arora
7a6fec3ea7 kube-proxy: internal config: add Windows section
Introduce Windows section for internal configuration of kube-proxy
adhering to the v1alpha2 version specifications as detailed in
https://kep.k8s.io/784. This also introduces WindowsRunAsService
to v1alpha1 configuration.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-07-15 22:43:47 +05:30
Kubernetes Prow Robot
2d4514e169 Merge pull request #125802 from mmorel-35/testifylint/len+empty
fix: enable empty and len rules from testifylint on pkg and staging package
2024-07-11 23:12:06 -07:00
Kubernetes Prow Robot
1740d85aff Merge pull request #125866 from aroradaman/can-use-nfacct
nfacct: conditionally ensure counters and register metrics
2024-07-10 19:26:36 -07:00
Daman Arora
33bac685a7 conditionally register nfacct metrics and ensure nfacct counters
If the nfacct sub-system is not available in the kernel then:
1. nfacct based metrics won't be registered.
2. proxier will not attempt to ensure the counters

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-07-09 18:49:01 +05:30
Daman Arora
75b18b86dd proxy/utils/nfacct: API to check if nfacct sub-system is present
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-07-09 18:44:04 +05:30
Kubernetes Prow Robot
db91d45d2d Merge pull request #124152 from danwinship/knftables-versions
update client/kernel version requirements for nftables kube-proxy
2024-07-08 12:45:02 -07:00
Dan Winship
b39fd03ee4 Allow disabling nftables kernel version check 2024-07-08 07:29:27 -04:00
Matthieu MOREL
f014b754fb fix: enable empty and len rules from testifylint on pkg package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>
2024-07-06 23:15:43 +00:00
Kubernetes Prow Robot
9039d71dd7 Merge pull request #124092 from princepereira/ppereira-updatelbpolicy-master
Adding modifyloadbalancer api support in Windows KubeProxy for update loadbalancer replacing usage of delete and create loadbalancer api.
2024-07-05 17:40:28 -07:00
Prince Pereira
ef2628d764 Adding support for ModifyLoadbalancer in windows kubeproxy. 2024-07-03 22:13:35 -07:00
Dan Winship
505f6833d9 Require kernel 5.13 for nftables kube-proxy 2024-07-01 10:07:27 -04:00
Dan Winship
912eca9e8b Reorganize nftables proxy init
Move the "nftables is supported" check into a separate function, and
call it before the --init-only return.
2024-07-01 10:07:27 -04:00
Kubernetes Prow Robot
93d56511e6 Merge pull request #125021 from aojea/servicecidrbeta
KEP-1880 Multiple Service CIDRs: Graduate to Beta (2/2)
2024-06-30 08:53:25 -07:00
Antonio Ojea
0e1f9dadd6 modify components to use the networking v1beta1 API 2024-06-30 09:48:46 +00:00
Matthieu MOREL
0cde5f1e28 fix: enable bool-compare rule from testifylint linter (#125135)
* fix: enable bool-compare rule from testifylint linter

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

* Update hack/golangci.yaml.in

Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>

* Update golangci.yaml.in

* Update golangci-strict.yaml

* Update golangci.yaml.in

* Update golangci.yaml.in

* Update golangci.yaml.in

* Update golangci.yaml.in

* Update golangci.yaml

* Update golangci-hints.yaml

* Update golangci-strict.yaml

* Update golangci.yaml.in

* Update golangci.yaml

* Update mux_test.go

---------

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>
2024-06-28 10:58:05 -07:00
Claudiu Belu
b5e3b81de6 unittests: Fixes unit tests for Windows (part 12)
Currently, there are some unit tests that are failing on Windows due
to various reasons:

- IPVS proxy mode is not supported on Windows.
- pkg/kubelet/cri/remote was moved to cri-client.
2024-06-28 08:05:38 +00:00
Kubernetes Prow Robot
eb6840928d Merge pull request #124160 from Karthik-K-N/fix-buildconstraints
Add doc.go file without any buildconstraint to run tests on non linux platforms
2024-06-13 16:29:06 -07:00
Quan Tian
9d71e5338d Remove unused sysctl parameter from nftables proxy
Signed-off-by: Quan Tian <quan.tian@broadcom.com>
2024-06-08 21:48:54 +08:00
Daman Arora
bc8b90b07d pkg/proxy: track localhost nodeport accepted packets
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-05-21 20:09:54 +05:30
Daman Arora
985d64cdbe add ct_state_invalid_dropped_pkts nfacct counter to unit tests
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-05-21 20:09:47 +05:30
Daman Arora
f7fae7297c pkg/proxy/metrics: refactor nfacct metrics collection
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-05-21 20:09:39 +05:30
HirazawaUi
facf702e64 Remove useless util functions 2024-05-20 19:57:43 +08:00
Kubernetes Prow Robot
41958b3c16 Merge pull request #124626 from danwinship/endpointslicecache
simplify EndpointSliceCache caching
2024-05-07 16:59:42 -07:00
Kubernetes Prow Robot
29a4812f03 Merge pull request #124080 from claudiubelu/skip-windows-tests
Skip failing Windows tests
2024-05-01 07:48:12 -07:00
Dan Winship
05e14799db Cache EndpointSlices directly rather than copying the data
Given that we are no longer modifying any of the EndpointSlice data,
we can just work with pointers to the actual EndpointSlice objects.
(The informer cache is already holding on to them, so they'll be
taking up memory whether or not the EndpointSliceCache points to
them.)
2024-04-29 17:07:21 -04:00
Dan Winship
f956fdf240 Don't sort endpointSliceData objects
EndpointSliceCache cached EndpointSlices into endpointSliceData
objects, in part so it could sort the ports and addresses, so that if
those fields got reordered without otherwise changing, it would not
trigger an OnEndpointSliceUpdate().

However, the EndpointSlice controller and mirroring controller always
output the ports in the same order, and they never reorder the
addresses of an existing slice unless the set of addresses actually
changed. So in the normal case, sorting the data adds more work than
it saves.
2024-04-29 17:07:21 -04:00
Dan Winship
f1f390f13b clean up LocalTrafficDetector construction / tests (#124582)
* LocalTrafficDetector construction and test improvements

* Reorder getLocalDetector unit test fields so "input" args come before "output" args

* Don't pass DetectLocalMode as a separate arg to getLocalDetector

It's already part of `config`

* Clarify test names in preparation for merging

* Merge single-stack/dual-stack LocalTrafficDetector construction

Also, only warn if the *primary* IP family is not correctly configured
(since we don't actually know if the cluster is really dual-stack or
not), and pass the pair of detectors to the proxiers as a map rather
than an array.

* Remove the rest of Test_getDualStackLocalDetectorTuple
2024-04-28 08:51:23 -07:00
Daman Arora
3363ec4ba1 pkg/proxy/iptables: track ct state invalid dropped packets
Track packets dropped by proxy which were marked invalid by conntrack
using nfacct netfilter extended accounting infrastructure.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-04-27 12:25:14 +05:30
Daman Arora
6b5291654f pkg/proxy/util/nfacct: utility to interact with nfacct subsystem
nfacct is netfilter's accounting subsystem. This utility allows
interactions with the subsystem using lower level netlink API.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-04-27 12:17:50 +05:30
Kubernetes Prow Robot
ae8474adcd Merge pull request #124557 from danwinship/metrics-and-stuff
kube-proxy metrics cleanup (and stuff)
2024-04-26 18:31:57 -07:00
Dan Winship
c4dd2c5ad7 Re-enable V(9) transaction logging in nftables proxy 2024-04-26 11:41:51 -04:00
Dan Winship
d4e6e62134 Add nftables cleanup failure metric, fix cleanup bug
If the sync fails, don't try to cleanup, since it's guaranteed to fail
too.
2024-04-26 11:41:51 -04:00
Dan Winship
3db434d6be Remove errors from LocalTrafficDetector constructors
The constructors only return an error if you pass them invalid data,
but we only ever pass them data which has already been validated,
making the error checking just annoying. Just make them return garbage
output if you give them garbage input.
2024-04-26 11:34:37 -04:00