Commit Graph

2142 Commits

Author SHA1 Message Date
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
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
Ziqi Zhao
be4535bd34 convert k8s.io/kubernetes/pkg/proxy to contextual logging, part 1
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
2024-04-22 13:08:41 +08:00
Kubernetes Prow Robot
bf07ef3950 Merge pull request #124383 from danwinship/nftables-proxy-to-beta
KEP-3866 kube-proxy nftables to beta
2024-04-18 17:42:20 -07:00
Dan Winship
fdf22533a8 KEP-3866 kube-proxy nftables mode to beta 2024-04-18 13:20:23 -04:00
Kubernetes Prow Robot
b2c32fb015 Merge pull request #123105 from danwinship/nodeport-addresses-primary
Add `--nodeport-addresses primary`, warn on empty `--nodeport-addresses`
2024-04-18 08:49:21 -07:00
Dan Winship
3ecd933276 fix/simplify an nftables unit test
The nodeport-ips value is part of the baseline, which wouldn't change
no matter what Services or EndpointSlices we added/removed.
2024-04-18 09:25:06 -04:00
Dan Winship
19b3a9e194 (Mostly) Revert "change --nodeport-addresses behavior to default to primary node ip only"
This reverts commit 8bccf4873b, except
for the nftables unit test changes, since we still want the "new"
results (not to mention the bugfixes), just for a different reason
now.
2024-04-18 09:25:06 -04:00
Dan Winship
0b599aa8e3 Add --nodeport-addresses primary
The behavior when you specify no --nodeport-addresses value in a
dual-stack cluster is terrible and we can't fix it, for
backward-compatibility reasons. Actually, the behavior when you
specify no --nodeport-addresses value in a single-stack cluster isn't
exactly awesome either...

Allow specifying `--nodeport-addresses primary` to get the
previously-nftables-backend-specific behavior of listening on only the
node's primary IP or IPs.
2024-04-18 09:25:06 -04:00
Dan Winship
8de0fc09aa Remove an unused type from kube-proxy config, move around some helpers 2024-04-13 11:12:28 -04:00
Nadia Pinaeva
56d1011aa5 kube-proxy: ensure nftables unit test parity with iptables.
Add packet tracing unit tests for ipv4 and ipv6.
Remove unreachable code from runChain, since some of the parsed rules
are never generated by the proxy implementation.

Signed-off-by: Nadia Pinaeva <n.m.pinaeva@gmail.com>
2024-04-02 11:57:47 +02:00
Nadia Pinaeva
1c7b366182 kube-proxy: rename iptables unit test to match tested function name.
Signed-off-by: Nadia Pinaeva <n.m.pinaeva@gmail.com>
2024-04-02 11:57:47 +02:00
Gaurav Ghildiyal
51f86b9124 Change kube-proxy behaviour to consider hints when ServiceTrafficDistribution feature gate is enabled 2024-03-03 22:46:03 -08:00
Kubernetes Prow Robot
98bd90fbe2 Merge pull request #114672 from pohly/log-text-split-streams
log: split streams also for text output
2024-02-26 01:44:58 -08:00
Antonin Bas
5fb002147b Remove unused Resolver interface in pkg/proxy/util
Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
2024-02-20 11:32:59 -08:00
Ayodele Abejide
71479b5577 [kube-proxy] add log verbosity to endpoint topology hint loop.
We enabled topology hint on one of our services and this log line was
emitted ~92 million times in one day from one cluster tripping our log
quota for that cluster, as it is the log line cannot be disabled via the
`-v` flag because it does not specify verbosity.

I think more log locations need to set verbosity at which they are
logged, but this one is currently hurting the most.
2024-02-15 18:26:19 +00:00
Quan Tian
42672ee2ea Make comment about reject action more accurate
Signed-off-by: Quan Tian <qtian@vmware.com>
2024-02-07 23:57:47 +08:00
Quan Tian
c7e48f1ebf kube-proxy: flush nftables base chains on startup
Do an extra "add+delete" once to ensure all previous base chains in the
table will be recreated. Otherwise, altering properties (e.g. priority)
of these chains would fail the transaction.

Signed-off-by: Quan Tian <qtian@vmware.com>
2024-02-07 23:57:40 +08:00
Kubernetes Prow Robot
27ad20db35 Merge pull request #123005 from danwinship/minor-proxy-cleanup
Minor proxy cleanup
2024-01-28 08:44:38 -08:00
Dan Winship
da05076868 Reorganize a bit of winkernel proxier setup
Rather than doing winkernel-specific parsing of generic config data in
cmd/kube-proxy, do it in pkg/proxy/winkernel.
2024-01-28 09:30:51 -05:00
Dan Winship
33bd5fb3c4 Remove unused param to winkernel proxier
The winkernel code was originally based on the iptables code but never
made use of some parts of it. (e.g., it logs a warning if you didn't
set `--cluster-cidr`, even though it doesn't actually use
`--cluster-cidr` if you do set it.)
2024-01-28 09:30:51 -05:00
Kubernetes Prow Robot
c4feb19195 Merge pull request #122878 from liggitt/typecheck-kube-proxy-darwin
Re-allow building kube-proxy on all platforms
2024-01-26 16:32:12 +01:00
Kubernetes Prow Robot
053acbed90 Merge pull request #122724 from nayihz/feat_nft_nodeport_addr
change --nodeport-addresses behavior to default to primary node ip only
2024-01-26 16:32:03 +01:00
Kubernetes Prow Robot
e023511deb Merge pull request #122920 from danwinship/knftables-migration
Update knftables, with new sigs.k8s.io module name
2024-01-26 07:14:16 +01:00
Jordan Liggitt
6a60a1ddad Mark conntrack/fake as linux-only, add non-OS doc.go 2024-01-25 23:15:49 -05:00
Dan Winship
ebba2d4472 Move some code in the proxiers
For no real reason, the core Proxier definitions weren't at the start
of the files.

(This just moves code around. It doesn't change anything.)
2024-01-25 18:41:58 -05:00
nayihz
8bccf4873b change --nodeport-addresses behavior to default to primary node ip only 2024-01-25 13:42:30 +08:00
Kubernetes Prow Robot
55f9657e07 Merge pull request #122692 from aroradaman/reject-packets-to-invalid-port
proxy/nftables: reject packets destined for invalid ports of service ips
2024-01-24 23:17:34 +01:00
Dan Winship
09abfa46be Update knftables, with new sigs.k8s.io module name 2024-01-23 08:09:05 -05:00
Daman Arora
25a40b1c7c pkg/proxy/nftables: handle traffic to node ports with no endpoints
NFTables proxy will no longer install drop and reject rules for node
port services with no endpoints in chains associated with forward and
output hooks.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-01-21 20:07:56 +05:30
Daman Arora
4b40299133 pkg/proxy/nftables: handle traffic to cluster ip
NFTables proxy will now drop traffic directed towards unallocated
ClusterIPs and reject traffic directed towards invalid ports of
Cluster IPs.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-01-21 19:58:37 +05:30
Daman Arora
01d7de5464 pkg/proxy/nftables: rename constant names for nftable objects
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-01-21 13:12:18 +05:30
Daman Arora
80ca91c90c pkg/proxy/nftables: refactor packet tracer address matching
Use bool instead of not-equal-operator as string in
tracer.addressMatches of helpers_test.go

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-01-21 12:53:55 +05:30