Commit Graph

708 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
fde1af55d2 Warn users with bad --nodeport-addresses
If users don't pass any --nodeport-addresses, suggest they should pass
`--nodeport-addresses primary`, to avoid accepting NodePort
connections on all interfaces.

If users pass a single-stack --nodeport-addresses in what looks like a
dual-stack cluster, warn them that they probably ought to be passing a
dual-stack --nodeport-addresses.
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
Kubernetes Prow Robot
501cfb7482
Merge pull request #123545 from yangjunmyfm192085/fixproxymetrics
fix:When the --bind-address parameter of kube-proxy is configured as ipv6, the ip address of metrics listens to 127.0.0.1 by default, instead of::1
2024-04-18 00:01:03 -07:00
杨军10092085
86a31ca302 fix:When the parameter of kube-proxy is configured as ipv6, the ip address of metrics listens to 127.0.0.1 by default, instead of::1 2024-04-16 08:56:49 +08:00
Kubernetes Prow Robot
f139450e9b
Merge pull request #122885 from claudiubelu/unittests-10
unittests: Fixes unit tests for Windows (part 10)
2024-02-28 05:38:40 -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
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
Dan Winship
536364266c Sort messy kube-proxy imports 2024-01-25 18:41:55 -05:00
Jordan Liggitt
d2c1a23a8a
Add stub methods for kube-proxy on non-linux/windows 2024-01-22 20:45:26 -08:00
Claudiu Belu
b8df7e7684 unittests: Fixes unit tests for Windows (part 10)
Currently, there are some unit tests that are failing on
Windows due to various reasons:

- Different "File not found" error messages on Windows.
- Files need to be closed on Windows before removing them.
- The default RootHnsEndpointName (root-hnsendpoint-name) flag value is 'cbr0'
- On Windows, Unix Domain sockets are not checked in the same way in golang, which is why
  hostutils_windows.go checks for it differently. GetFileType will return an error in this
  case. We need to check for it, and see if it's actually a Unix Domain Socket.
2024-01-22 13:43:42 +00:00
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
Patrick Ohly
8f4c9c7605 k8s.io/component-base/logs: replace klog text implementation
This replaces the klog formatting and message routing with a simpler
implementation that uses less code. The main difference is that we skip the
entire unused message routing.

Instead, the same split output streams as for JSON gets implemented in the
io.Writer implementation that gets passed to the textlogger.
2024-01-17 13:50:03 +01:00
Lars Ekman
50b3ffc71f kube-proxy: LoadBalancerSourceRanges as *net.IPNet 2024-01-09 09:17:56 +01:00
Lars Ekman
564b80b1e1 kube-proxy: don't use invalid cidrs in unit test
CIDRs like 192.168.200.3/24 and fd00:20::1/64 replaced with
192.168.200.0/24 and fd00:20::/64
2024-01-09 09:17:31 +01:00
Ziqi Zhao
6b5e973e5f
Migrate cmd/kube-proxy to contextual logging (#122197)
* cmd/kube-proxy support contextual logging

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

* use ktesting.NewTestContext(t) in unit test

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

* use ktesting.NewTestContext(t) in unit test

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

* remove unnecessary blank line & add cmd/kube-proxy to contextual section in logcheck.conf

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

* add more contextual logging

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

* new lint yaml

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>

---------

Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
2024-01-08 17:30:18 +01:00
Dan Winship
c1ce1e00ee Properly build-tag the Linux kube-proxy backend code
This had to be able to build on OS X before to make verify-typecheck
pass, but now that that's fixed we can tag the code properly as being
linux-only.
2023-12-18 20:20:51 -05:00
Dan Winship
93860a5217 Distinguish iptables-based and nftables-based backends, do startup cleanup
When switching from iptables or ipvs to nftables, clean up old
iptables/ipvs rules. When switching the other way, clean up old
nftables rules.
2023-10-31 17:38:32 -04:00
Dan Winship
abb1a458a9 Create an nftables.Interface in nftables proxier
And update most of the comments to refer to "nftables" rather than
"iptables" (even though it doesn't actually do any nftables updating
at this point).

For now the proxy also internally creates a
utiliptablestesting.FakeIPTables to keep the existing sync code
compiling.
2023-10-31 17:38:29 -04:00
Dan Winship
1a6b9b811e Simplify nftables/proxier.go by removing localhost nodeport support
and related route_localnet setting / anti-martian-packet rule
2023-10-31 17:33:53 -04:00
Dan Winship
a70653143e Add a dummy nftables kube-proxy backend which is just a copy of iptables 2023-10-31 17:31:42 -04:00
Kubernetes Prow Robot
0c93f40374
Merge pull request #120995 from aroradaman/move-get-kernel-version
move GetKernelVersion out of pkg/proxy/ipvs
2023-10-31 20:23:41 +01:00
Daman Arora
9ae77364e9 pkg/proxy: configure tcp-be-liberal
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2023-10-28 01:11:24 +05:30
Daman Arora
a375aa28ee pkg/proxy: move get kernel version out of ipvs proxier
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2023-10-28 00:54:34 +05:30
Lars Ekman
4b59d2b05c kube-proxy: Optionally do privileged configs only
A new --init-only flag is added tha makes kube-proxy perform
configuration that requires privileged mode and exit. It is
intended to be executed in a privileged initContainer, while
the main container may run with a stricter securityContext
2023-10-24 07:01:31 +02:00
Kubernetes Prow Robot
b5ba899dfa
Merge pull request #118146 from aroradaman/fix/proxy-healthzserver
proxy healthz server for dualstack clusters
2023-10-16 21:19:25 +02:00
Daman Arora
bfda244e54 pkg/proxy: dual stack health checker
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2023-10-16 16:11:18 +05:30
Daman Arora
4ea6ec738c pkg/proxy: add an ipFamily field to the winkernel proxier
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2023-10-15 19:55:09 +05:30
Kubernetes Prow Robot
cf54acce5c
Merge pull request #120274 from danwinship/kube-proxy-config-docs
kube-proxy config/CLI doc fixups
2023-10-15 02:56:24 +02:00
Kubernetes Prow Robot
b47aa1c20e
Merge pull request #120808 from aroradaman/proxy-conntrack-udp-timeouts
Adding option to configure UDP timeouts for conntrack
2023-10-12 01:59:55 +02:00
Daman Arora
15ae6cc160 pkg/proxy: add flag to configure udp conntrack timeouts
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2023-10-12 03:08:21 +05:30
Dan Winship
f3c786cbda Fix regression in cmd/kube-proxy/app unit test speed 2023-10-09 07:08:22 -04:00
Dan Winship
b2f0052d27 Make a certain ipv4-vs-ipv6 config error non-fatal, for backward compat 2023-10-05 12:57:29 -04:00
Dan Winship
9242cb1934 Rearrange kube-proxy config fields / CLI flags to make more sense. 2023-09-30 10:19:07 -04:00
Dan Winship
44cb330aa0 Improve kube-proxy config / CLI documentation 2023-09-30 10:18:16 -04:00
Kubernetes Prow Robot
dc28eeaa3a
Merge pull request #120565 from skitt/drop-deprecated-pointer-kube-proxy
kube-proxy: drop deprecated pointer package
2023-09-29 02:24:42 -07:00
Kubernetes Prow Robot
d393d4e151
Merge pull request #120574 from logicalhan/cslis
promote component SLIs to GA; remove feature gates for component slis
2023-09-14 22:52:12 -07:00
Lars Ekman
0df4a69f5c
Kube-proxy: Get nodeIPs for both families with dual-stack (#119525)
* Kube-proxy: handle dual-stack in detectNodeIPs()

* Updates
2023-09-11 09:30:23 -07:00
Han Kang
e6435e98ed promote component SLIs to GA; remove feature gates for component slis 2023-09-11 09:15:32 -07:00
Stephen Kitt
357d7804b8
kube-proxy: drop deprecated pointer package
This replaces deprecated k8s.io/utils/pointer functions with their ptr
equivalent.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2023-09-11 16:38:37 +02:00