Commit Graph

2174 Commits

Author SHA1 Message Date
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
Dan Winship
fc05a294cc Rename nftables sync failure metric 2024-04-26 09:27:41 -04:00
Dan Winship
1823de063b fix "Iptables" -> "IPTables" in metrics variable names 2024-04-26 09:27:41 -04:00
Dan Winship
ba57fd7c84 Merge linux and windows kube-proxy metric registration together
Windows proxy metric registration was in a separate file, which had
led to some metrics (eg the new ProxyHealthzTotal and ProxyLivezTotal)
not being registered for Windows even though they were implemented by
platform-generic code.

(A few other metrics were neither registered on, nor implemented on
Windows, and that's probably a bug.)

Also, beyond linux-vs-windows, make it clearer which metrics are
specific to individual backends.
2024-04-26 09:27:41 -04:00
Claudiu Belu
2be8baeaef unittests: Skip failing Windows tests
Some of the unit tests are currently failing on Windows.

Skip them for now, and remove the skips later, once the underlying issues
have been resolved.
2024-04-25 14:24:16 +00:00
Dan Winship
59cecf8a36 Simplify redundant LocalTrafficDetector implementations
All of the LocalTrafficDetector implementations were essentially
identical after construction time, so just reduce them to a single
implementation with multiple constructors.

Also, improve the comments.
2024-04-25 08:52:35 -04:00
Dan Winship
dc1155bd53 Move LocalTrafficDetector from pkg/proxy/util/iptables to pkg/proxy/util
Since it's used for nftables as well now.
2024-04-25 08:51:43 -04:00
Marek Siarkowicz
3ee8178768 Cleanup defer from SetFeatureGateDuringTest function call 2024-04-24 20:25:29 +02:00
Kubernetes Prow Robot
06db9962f8 Merge pull request #124452 from danwinship/proxy-config-unit-tests
KubeProxyConfig unit test cleanups
2024-04-24 09:47:35 -07:00
Daman Arora
a577c0b324 kube-proxy: refactor config validation unit test
Refactor the TestValidateKubeProxyConfiguration by adding a mutating
function that adjusts the configuration according to each test case,
thereby enhancing readability.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-04-23 09:03:42 -04:00
Dan Winship
f4ecae8324 Use t.Run and assert.Equal in KubeProxyConfiguration validation tests 2024-04-23 09:03:23 -04:00
Dan Winship
7b9f730804 Merge success and failure cases in KubeProxyConfiguration validation tests 2024-04-23 09:03:23 -04:00
Dan Winship
c7f3caf498 Add names to all KubeProxyConfiguration validation test cases 2024-04-23 09:03:21 -04:00
Dan Winship
7320e54e0e Split Linux/Windows TestValidateKubeProxyMode 2024-04-22 18:25:01 -04:00