Commit Graph

615 Commits

Author SHA1 Message Date
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
Patrick Ohly
bc6c7fa912 logging: fix names of keys
The stricter checking with the upcoming logcheck v0.4.1 pointed out these names
which don't comply with our recommendations in
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md#name-arguments.
2023-01-23 14:24:29 +01:00
Patrick Ohly
66dfac3b18 kube-proxy: support the logging feature gates
When trying to bring up a cluster via kubeadm with these feature gates enabled,
kube-proxy fails because it didn't know about them:

    kind: Cluster
    apiVersion: kind.x-k8s.io/v1alpha4
    nodes:
    - role: control-plane
    - role: worker
    - role: worker
    featureGates: {"DynamicResourceAllocation":true,"ContextualLogging":true}
    runtimeConfig: {"resource.k8s.io/v1alpha1":"true"}

    =>

    2023-01-20T07:07:54.474966617Z stderr F E0120 07:07:54.474846       1 run.go:74] "command failed" err="failed complete: unrecognized feature gate: ContextualLogging"

The effect of the logging feature gates is minor for kube-proxy, supporting
them is mostly useful for the sake of consistency and to support kubeadm.
2023-01-20 19:31:57 +01:00
Kubernetes Prow Robot
280473ebc4
Merge pull request #114773 from yangjunmyfm192085/fixsmallerrorlog
fix a small log error about proxy
2023-01-11 07:51:43 -08:00
Dan Winship
169604d906 Validate single-stack --nodeport-addresses sooner
In the dual-stack case, iptables.NewDualStackProxier and
ipvs.NewDualStackProxier filtered the nodeport addresses values by IP
family before creating the single-stack proxiers. But in the
single-stack case, the kube-proxy startup code just passed the value
to the single-stack proxiers without validation, so they had to
re-check it themselves. Fix that.
2023-01-03 09:01:45 -05:00
Dan Winship
e7ed7220eb Explicitly pass IP family to proxier
Rather than re-determining it from the iptables object in both proxies.
2023-01-03 09:01:45 -05:00
Dan Winship
fb84c4f0f0 Fix kube-proxy dual-stack-iptables-binary-presence check
Kube-proxy was checking that iptables supports both IPv4 and IPv6 and
falling back to single-stack if not. But it always fell back to the
primary IP family, regardless of which family iptables supported...
Fix it so that if the primary IP family isn't supported then it bails
out entirely.
2023-01-03 09:01:35 -05:00
JunYang
281a2bdd2f fix a small log error about proxy 2023-01-03 20:07:20 +08:00
JunYang
cc4126a010 use klog.InfoS instead of klog.V(0).Info-proxy part 2022-12-29 11:16:51 +08:00
Lars Ekman
cd15ca0548 proxy/ipvs: Check that a dummy virtual server can be added
This tests both ipvs and the configured scheduler
2022-12-22 20:36:53 +01:00
cyclinder
bef2070031
kube-proxy: add a flag to disables the allowing NodePort services to be accessed via localhost 2022-11-02 16:17:52 +08:00
Antonio Ojea
75913e9949 kube-proxy wait for cluster cidr skip delete events 2022-10-18 19:29:09 +00:00
Antonio Ojea
a38b9363ec kube-proxy handle node PodCIDR changs
Kube/proxy, in NodeCIDR local detector mode, uses the node.Spec.PodCIDRs
field to build the Services iptables rules.

The Node object depends on the kubelet, but if kube-proxy runs as a
static pods or as a standalone binary, it is not possible to guarantee
that the values obtained at bootsrap are valid, causing traffic outages.

Kube-proxy has to react on node changes to avoid this problems, it
simply restarts if detect that the node PodCIDRs have changed.

In case that the Node has been deleted, kube-proxy will only log an
error and keep working, since it may break graceful shutdowns of the
node.
2022-10-18 19:25:40 +00:00
Claudiu Belu
af77381e01 unit tests: Skip Windows-unrelated tests on Windows
Some of the unit tests cannot pass on Windows due to various reasons:

- fsnotify does not have a Windows implementation.
- Proxy Mode IPVS not supported on Windows.
- Seccomp not supported on Windows.
- VolumeMode=Block is not supported on Windows.
- iSCSI volumes are mounted differently on Windows, and iscsiadm is a
  Linux utility.
2022-10-18 12:43:07 +03:00
Kubernetes Prow Robot
b6e8dfec61
Merge pull request #113057 from Richabanker/kube-proxy-metrics-slis
add metrics/slis to kube-proxy health checks
2022-10-15 06:49:05 -07:00
Kubernetes Prow Robot
6705015101
Merge pull request #112133 from knabben/remove-kproxy-userspace
Remove kube-proxy userspace modes
2022-10-14 17:31:06 -07:00
Richa Banker
10903cb796 add metrics/slis to kube-proxy health checks 2022-10-13 12:57:28 -07:00
Paco Xu
2ce7a81169 fsnotify: use event.Has instead of "event.Op&h == h" 2022-10-13 13:42:26 +08:00
Amim Knabben
7df6c02288 Remove Linux and Windows Kube-proxy Userspace mode 2022-10-05 16:59:02 -03:00
Han Kang
e95179ffb6 Wire up feature_gate.go with metrics via AddMetrics method
wire up feature_gate.go with metrics via AddMetrics method

Change-Id: I9b4f6b04c0f4eb9bcb198b16284393d21c774ad8

wire in metrics to kubernetes components

Change-Id: I6d4ef8b26f149f62b03f32d1658f04f3056fe4dc

rename metric since we're using the value to determine if enabled is true or false

Change-Id: I13a6b6df90a5ffb4b9c5b34fa187562413bea029

Update staging/src/k8s.io/component-base/featuregate/feature_gate.go

Co-authored-by: Jordan Liggitt <jordan@liggitt.net>
2022-09-26 08:44:42 -07:00
JunYang
2db4dea565 use klog.InfoS instead of klog.V(0).InfoS 2022-08-25 18:46:34 +08:00
Kubernetes Prow Robot
f313ef501a
Merge pull request #111833 from ialidzhikov/cleanup/cmd-kube-proxy
cmd/kube-proxy: Replace deprecated func usage from the `k8s.io/utils/pointer` pkg
2022-08-24 13:31:49 -07:00
Kubernetes Prow Robot
da112dda68
Merge pull request #111806 from danwinship/kube-proxy-no-mode-fallback
remove kube-proxy mode fallback
2022-08-24 05:52:03 -07: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
1609017f2b kube-proxy: remove ipvs-to-iptables fallback
If the user passes "--proxy-mode ipvs", and it is not possible to use
IPVS, then error out rather than falling back to iptables.

There was never any good reason to be doing fallback; this was
presumably erroneously added to parallel the iptables-to-userspace
fallback (which only existed because we had wanted iptables to be the
default but not all systems could support it).

In particular, if the user passed configuration options for ipvs, then
they presumably *didn't* pass configuration options for iptables, and
so even if the iptables proxy is able to run, it is likely to be
misconfigured.
2022-08-16 09:30:08 -04:00
Dan Winship
9f69a3a9d4 kube-proxy: remove iptables-to-userspace fallback
Back when iptables was first made the default, there were
theoretically some users who wouldn't have been able to support it due
to having an old /sbin/iptables. But kube-proxy no longer does the
things that didn't work with old iptables, and we removed that check a
long time ago. There is also a check for a new-enough kernel version,
but it's checking for a feature which was added in kernel 3.6, and no
one could possibly be running Kubernetes with a kernel that old. So
the fallback code now never actually falls back, so it should just be
removed.
2022-08-16 09:21:34 -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
ialidzhikov
17c14ced18 cmd/kube-proxy: Replace deprecated func usage from the k8s.io/utils/pointer pkg 2022-08-13 22:01:02 +03:00
SataQiu
25a81a7514 kube-proxy: optimize the format of the flag usage string 2022-08-11 19:37:25 +08:00
pandaamanda
fbe934da21 kube-proxy: kernelspace mode is announced to be default for windows 2022-07-18 01:04:56 +00:00
Surya Seetharaman
7d480d8ac8 Enable local traffic detection using the interface options
This commit adds the framework for the new local detection
modes BridgeInterface and InterfaceNamePrefix to work.

Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
2022-03-25 20:06:12 +01: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
Tyler Lloyd
a7d866f036
chore: kube-proxy cluder-cidr arg accepts comma-separated list (#105832)
* kube-proxy cluder-cidr arg accepts comma-separated list

It is possible in dual-stack clusters to provide kube-proxy with
a comma-separated list with an IPv4 and IPv6 CIDR for pods.

update: signoff
update2: update email profile

Signed-off-by: Tyler Lloyd <Tyler.Lloyd@microsoft.com>
Signed-off-by: Tyler Lloyd <tylerlloyd928@gmail.com>

* Updating cluster-cidr comment description

Signed-off-by: Tyler Lloyd <tyler.lloyd@microsoft.com>
2022-03-11 02:03:07 -08:00
Wojciech Tyczyński
ef2e32ab65 Log main golang runtime env vars 2022-03-04 08:04:02 +01:00
ahrtr
972dc46a1f replace deprecated io/ioutil with os and io for cmd 2022-02-01 13:59:41 +08:00
haoyun
732cb36725 fix: misleading in help info
Signed-off-by: haoyun <yun.hao@daocloud.io>
2022-01-07 14:50:31 +08:00
Kubernetes Prow Robot
d0d23ea052
Merge pull request #107157 from chendave/proxy-config
kube-proxy: note that cli args is ignored if config file is specified
2021-12-21 12:44:25 -08:00
Dave Chen
e5eb158877 kube-proxy: note that cli args is ignored if config file is specified
Signed-off-by: Dave Chen <dave.chen@arm.com>
2021-12-21 17:04:47 +08:00
Kubernetes Prow Robot
1d66302c42
Merge pull request #106458 from dims/lint-yaml-in-owners-files
Lint/Beautify yaml in OWNERS files
2021-12-10 06:39:12 -08:00
Kubernetes Prow Robot
15e5f2a19a
Merge pull request #106291 from sbs2001/fix_invalid_comment
Remove invalid comment in legacyregistry
2021-12-09 19:03:10 -08:00
Davanum Srinivas
9405e9b55e
Check in OWNERS modified by update-yamlfmt.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-12-09 21:31:26 -05:00
Amim Knabben
8b37bfec8e Enabling kube-proxy metrics on windows kernel mode 2021-11-21 21:23:55 -03:00
Shivam Sandbhor
6652c54d83 Remove invalid comment in legacyregistry
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
2021-11-18 15:05:00 +05:30
Hanna Lee
07a883d8e6 Remove //lint:ignore pragmas that aren't being used anymore 2021-11-17 08:56:54 +01:00
Hanna Lee
30ea05ae7b Update IPVar and IPPortVar functions to have pointer receivers to fix 'ineffective assignment' 2021-11-17 08:56:00 +01:00
Hanna Lee
0f3836dcc5 Ignore deprecation warnings with //nolint:staticcheck 2021-11-17 08:55:57 +01:00
sanposhiho
c169d4d4d2 Fix: change not to print error log on RunE 2021-11-13 14:21:04 +09:00
sanposhiho
f80ddac1bc Fix: return error instead of os.Exit when something goes wrong 2021-11-13 14:20:56 +09:00
Neha Lohia
fa1b6765d5
move pkg/util/node to component-helpers/node/util (#105347)
Signed-off-by: Neha Lohia <nehapithadiya444@gmail.com>
2021-11-12 07:52:27 -08:00
Kubernetes Prow Robot
c98b388a84
Merge pull request #105450 from danwinship/ipvs-dead-code
Remove some dead code in the ipvs proxy
2021-11-11 20:50:27 -08:00