Commit Graph

369 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Shivanshu Raj Shrivastava
d3f81a1be6
Migrated server.go, ipvs/proxier.go(partial) to structured logging (#105769)
* fixed improperly migrated logs

* fixed improperly migrated logs

* fixed improperly migrated logs

* fixed improperly migrated logs

* Update cmd/kube-proxy/app/server.go

Co-authored-by: Marek Siarkowicz <marek.siarkowicz@protonmail.com>

* Update pkg/proxy/ipvs/proxier.go

Co-authored-by: Marek Siarkowicz <marek.siarkowicz@protonmail.com>

* Update pkg/proxy/ipvs/proxier.go

Co-authored-by: Marek Siarkowicz <marek.siarkowicz@protonmail.com>

* Update pkg/proxy/ipvs/proxier.go

Co-authored-by: Marek Siarkowicz <marek.siarkowicz@protonmail.com>

* Update pkg/proxy/ipvs/proxier.go

Co-authored-by: Marek Siarkowicz <marek.siarkowicz@protonmail.com>

Co-authored-by: Marek Siarkowicz <marek.siarkowicz@protonmail.com>
2021-10-20 02:54:11 -07:00
jonyhy
1ff266b779 fix: ignore error
Signed-off-by: jonyhy <yun.hao@daocloud.io>
2021-10-09 09:26:27 +08:00
Patrick Ohly
00e4a599f6 command lines: always show flags with hyphens
All Kubernetes commands should show flags with hyphens in their help text even
when the flag originally was defined with underscore. Converting a command to
this style is not breaking its command line API because the old-style parameter
with underscore is accepted as alias.

The easiest solution to achieve this is to set normalization shortly before
running the command in the new central cli.Run or the few places where that
function isn't used yet.

There may be some texts which depends on normalization at flag definition time,
like the --logging-format usage warning. Those get generated assuming that
hyphens will be used.
2021-09-30 13:46:49 +02:00
Patrick Ohly
21d1bcd6b8 initialize logging after flag parsing
It wasn't documented that InitLogs already uses the log flush frequency, so
some commands have called it before parsing (for example, kubectl in the
original code for logs.go). The flag never had an effect in such commands.

Fixing this turned into a major refactoring of how commands set up flags and
run their Cobra command:

- component-base/logs: implicitely registering flags during package init is an
  anti-pattern that makes it impossible to use the package in commands which
  want full control over their command line. Logging flags must be added
  explicitly now, something that the new cli.Run does automatically.

- component-base/logs: AddFlags would have crashed in kubectl-convert if it
  had been called because it relied on the global pflag.CommandLine. This
  has been fixed and kubectl-convert now has the same --log-flush-frequency
  flag as other commands.

- component-base/logs/testinit: an exception are tests where flag.CommandLine has
  to be used. This new package can be imported to add flags to that
  once per test program.

- Normalization of the klog command line flags was inconsistent. Some commands
  unintentionally didn't normalize to the recommended format with hyphens. This
  gets fixed for sample programs, but not for production programs because
  it would be a breaking change.

This refactoring has the following user-visible effects:

- The validation error for `go run ./cmd/kube-apiserver --logging-format=json
  --add-dir-header` now references `add-dir-header` instead of `add_dir_header`.

- `staging/src/k8s.io/cloud-provider/sample` uses flags with hyphen instead of
  underscore.

- `--log-flush-frequency` is not listed anymore in the --logging-format flag's
  `non-default formats don't honor these flags` usage text because it will also
  work for non-default formats once it is needed.

- `cmd/kubelet`: the description of `--logging-format` uses hyphens instead of
  underscores for the flags, which now matches what the command is using.

- `staging/src/k8s.io/component-base/logs/example/cmd`: added logging flags.

- `apiextensions-apiserver` no longer prints a useless stack trace for `main`
  when command line parsing raises an error.
2021-09-30 13:46:49 +02:00
Dan Winship
7f6fbc4482 Drop broken/no-op proxyconfig.EndpointsHandler implementations
Because the proxy.Provider interface included
proxyconfig.EndpointsHandler, all the backends needed to
implement its methods. But iptables, ipvs, and winkernel implemented
them as no-ops, and metaproxier had an implementation that wouldn't
actually work (because it couldn't handle Services with no active
Endpoints).

Since Endpoints processing in kube-proxy is deprecated (and can't be
re-enabled unless you're using a backend that doesn't support
EndpointSlice), remove proxyconfig.EndpointsHandler from the
definition of proxy.Provider and drop all the useless implementations.
2021-09-13 09:32:38 -04:00
Antonio Ojea
0cd75e8fec run hack/update-netparse-cve.sh 2021-08-20 10:42:09 +02:00
yxxhero
38239d3025 migrate cmd/kube-proxy/app logs to structured logging 2021-07-20 23:07:41 +08:00
Kubernetes Prow Robot
76b0906136
Merge pull request #101047 from jsturtevant/issue-100966-dualstack-windows
[sig-windows] update winkernel to only use dualstack if the node and config supports it
2021-07-15 20:30:09 -07:00
Davanum Srinivas
07332ad398
fix ineffassign and varcheck
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-07-14 08:41:22 -04:00
Davanum Srinivas
26cc8e40a8
fix deadcode issues
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-07-14 08:41:21 -04:00
James Sturtevant
d5d9327351 Only use dualstack if the node and config supports it 2021-07-08 11:39:20 -07:00
Kubernetes Prow Robot
96dff7d0c7
Merge pull request #102832 from Yuan-Junliang/migrateProxyEventAPI
Migrate kube-proxy event to use v1 Event API
2021-07-05 17:44:17 -07:00
Kubernetes Prow Robot
d95c46a3e5
Merge pull request #98306 from borgerli/kube-proxy-log
Support dynamically set log level for kube-proxy
2021-07-05 03:23:05 -07:00
Swetha Repakula
03b7a699c2 Kubeproxy uses V1 EndpointSlice 2021-06-30 18:41:57 -07:00
krak7602
ec93b3b0be Stop using github.com/pkg/errors 2021-06-22 10:43:30 +05:30
Yuan-Junliang
2e06066bab Migrate kube-proxy to use v1 Event API 2021-06-13 18:57:52 +08:00
Andrew Sy Kim
d96af5f276 kube-proxy: remove ServiceTopology implementation
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-03 22:17:46 -04:00
Li Bo
6e54f067e9 Support dynamically set log level for kube-proxy 2021-04-05 12:54:27 +08:00
Rob Scott
f07be06a19
Adding support for TopologyAwareHints to kube-proxy 2021-03-08 15:37:47 -08:00