Commit Graph

73 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
Dan Winship
1f2bf32e95 Figure out single-stack/dual-stack support before creating the proxier
Rather than having this as part of createProxier(), explicitly figure
out what IP families the proxier can support beforehand, and bail out
if this conflicts with the detected IP family.
2023-06-30 17:43:04 -04:00
Dan Winship
8abfa89e82 Move proxy platformSetup call, and do LocalDetector setup from there 2023-06-30 17:39:36 -04:00
Dan Winship
4962e6eacb Squash detectNodeIP and nodeIPTuple together 2023-06-06 20:48:00 -04:00
Dan Winship
6232ac734a Merge duplicated Linux/Windows kube-proxy setup code 2023-05-23 16:17:07 -04:00
Dan Winship
08ce580576 Add ProxyServer.platformSetup
Move the Linux-specific conntrack setup code into a new
"platformSetup" rather than trying to fit it into the generic setup
code.

Also move metrics registration there.
2023-05-23 16:17:04 -04:00
Dan Winship
10a869fc75 Remove duplicated config fields from ProxyServer
Rather than duplicating some of the KubeProxyConfiguration into
ProxyServer, just store the KubeProxyConfiguration itself so later
code can reference it directly.

For the fields that get platform-specific defaults (Mode,
DetectLocalMode), fill the defaults directly into the
KubeProxyConfiguration rather than keeping the original there and the
defaulted version in the ProxyServer.
2023-05-03 10:15:37 -04:00
Dan Winship
3734fe7ab1 Remove some useless error checks
Don't return errors in the event of programmer errors, and don't
double-check things that were already validated.
2023-05-03 08:22:45 -04:00
Paco Xu
e28f3de656
Revert "proxy startup-time config handling cleanup" 2023-04-30 09:05:42 +08:00
Dan Winship
258c4c4251 Remove duplicated config fields from ProxyServer
Rather than duplicating some of the KubeProxyConfiguration into
ProxyServer, just store the KubeProxyConfiguration itself so later
code can reference it directly.

For the fields that get platform-specific defaults (Mode,
DetectLocalMode), fill the defaults directly into the
KubeProxyConfiguration rather than keeping the original there and the
defaulted version in the ProxyServer.
2023-04-27 15:43:35 -04:00
Dan Winship
a96358ac0f Remove some useless error checks
Don't return errors in the event of programmer errors, and don't
double-check things that were already validated.
2023-04-13 19:50:26 -04:00
Dan Winship
be101a748d Remove some unused winkernel arguments/fields/functions
The winkernel proxy was originally created by copying+pasting from the
iptables code, but some iptables-specific things were never removed
(and one function got left behind after its functionality was moved
into the shared proxy code).
2023-04-12 09:41:38 -04:00
Dan Winship
8a790ac2e1 Remove unused ProxyServer.EventClient field
The port to Events v1 left some cruft behind.
2023-04-12 09:41:38 -04:00
Dan Winship
f994ae2521 Move GetHostname() from k/k/pkg/util/node to k/component-helpers/node/util
In fact, this actually uses pkg/util/node's GetHostname() but takes
the unit tests from cmd/kubeadm/app/util's private fork of that
function since they were more extensive. (Of course the fact that
kubeadm had a private fork of this function is a strong argument for
moving it to component-helpers.)
2023-01-27 18:24:38 -05:00
JunYang
cc4126a010 use klog.InfoS instead of klog.V(0).Info-proxy part 2022-12-29 11:16:51 +08:00
Amim Knabben
7df6c02288 Remove Linux and Windows Kube-proxy Userspace mode 2022-10-05 16:59:02 -03:00
JunYang
2db4dea565 use klog.InfoS instead of klog.V(0).InfoS 2022-08-25 18:46:34 +08:00
Dan Winship
946ce55b04 kube-proxy: use API constants for proxy modes rather than local redefinitions 2022-08-16 09:30:42 -04:00
Dan Winship
477d14e53b Reorganize "kube-proxy --cleanup-and-exit"
This was implemented partly in server.go and partly in
server_others.go even though even the parts in server.go were totally
linux-specific. Simplify things by putting it all in server_others.go
and get rid of some unnecessary abstraction.
2022-08-16 09:16:05 -04:00
Yongkun Gui
78a507b256 Fix health check from Google's Load Balancer
This change adds 2 options for windows:
--forward-healthcheck-vip: If true forward service VIP for health check
port
--root-hnsendpoint-name: The name of the hns endpoint name for root
namespace attached to l2bridge, default is cbr0

When --forward-healthcheck-vip is set as true and winkernel is used,
kube-proxy will add an hns load balancer to forward health check request
that was sent to lb_vip:healthcheck_port to the node_ip:healthcheck_port.
Without this forwarding, the health check from google load balancer will
fail, and it will stop forwarding traffic to the windows node.

This change fixes the following 2 cases for service:
- `externalTrafficPolicy: Cluster` (default option): healthcheck_port is
10256 for all services. Without this fix, all traffic won't be directly
forwarded to windows node. It will always go through a linux node and
get forwarded to windows from there.
- `externalTrafficPolicy: Local`: different healthcheck_port for each
service that is configured as local. Without this fix, this feature
won't work on windows node at all. This feature preserves client ip
that tries to connect to their application running in windows pod.

Change-Id: If4513e72900101ef70d86b91155e56a1f8c79719
2022-03-11 22:34:59 -08:00
Amim Knabben
8b37bfec8e Enabling kube-proxy metrics on windows kernel mode 2021-11-21 21:23:55 -03:00
Peri Thompson
b476eaade4 Adding deprecation notice to the userspace proxy-mode 2021-08-31 10:19:00 +01:00
Stephen Augustus
481cf6fbe7
generated: Run hack/update-gofmt.sh
Signed-off-by: Stephen Augustus <foo@auggie.dev>
2021-08-24 15:47:49 -04:00
Antonio Ojea
0cd75e8fec run hack/update-netparse-cve.sh 2021-08-20 10:42:09 +02:00
James Sturtevant
d5d9327351 Only use dualstack if the node and config supports it 2021-07-08 11:39:20 -07:00
Swetha Repakula
0a42f7b989 Graduate EndpointSliceProxying and WindowsEndpointSliceProxying Gates 2021-07-07 13:33:30 -07:00
Yuan-Junliang
2e06066bab Migrate kube-proxy to use v1 Event API 2021-06-13 18:57:52 +08:00
Kubernetes Prow Robot
3d5ebcc37f
Merge pull request #101410 from songxiao-wang87/run-test5
Structured Logging migration: modify server_windows part logs of kube-proxy.
2021-04-27 14:53:39 -07:00
jornshen
c842cc5247 no watch endpointslice in userpace mode 2021-04-26 20:31:59 +08:00
songxiao-wang87
8eea052206 Making a run test.
Signed-off-by: songxiao-wang87 <wang.xiaosong23@zte.com.cn>
2021-04-23 16:01:29 +08:00
xh4n3
d6bc98fc5a fix wrong NumCPU in kube-proxy under static CPU policy
Signed-off-by: xh4n3 <xyn1016@gmail.com>
2021-03-05 12:38:05 +08:00
Zhang Zhanpeng
10111eb499 Optimized function getProxyMode
Signed-off-by: Zhang Zhanpeng <zhanpeng.zhang@daocloud.io>
2021-02-24 10:17:11 +08:00
Rob Scott
8039cf9bb1
Graduating EndpointSliceProxying to beta for Linux 2020-07-07 14:18:03 -07:00
Vinod K L Swamy
bbd4a07dec
Changes to WinKernel to support EndpointSlices 2020-06-29 14:31:15 -07:00
Vinod K L Swamy
ac3f87346f
KubeProxy and DockerShim changes for Ipv6 dual stack support on Windows
Signed-off-by: Vinod K L Swamy <vinodko@microsoft.com>
2020-06-10 15:36:48 -07:00
Davanum Srinivas
442a69c3bd
switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:27 -04:00
cici37
7f4d19167e Move pkg/util/configz to k8s.io/component-base 2020-04-29 12:17:25 -07:00
SataQiu
871b90ba23 kube-proxy: add '--bind-address-hard-fail' flag to treat failure to bind to a port as fatal
Signed-off-by: SataQiu <1527062125@qq.com>
2020-04-02 13:13:10 +08:00
Ted Yu
7a0690cd59 Use ProxierHealthUpdater directly to avoid panic 2020-02-10 09:41:09 -08:00
RainbowMango
9b7d8712cf Add show hidden flag to kube-proxy 2019-12-17 21:46:41 +08:00