Commit Graph

1831 Commits

Author SHA1 Message Date
Dan Winship
88a3c6924e topology_test.go: merge tests into a single test
Move all of the tests into TestFilterEndpoints, rather than separately
testing some of its internal helper functions (which will be going
away).
2022-02-14 10:17:03 -05:00
Dan Winship
6caa18a6b7 topology_test.go: remove unnecessary helper type
Remove the `endpoint` type, and just use `Endpoint` directly in the
testCases.
2022-02-14 10:16:59 -05:00
Dan Winship
e5ba48f7d1 topology_test.go: simplify expected result checking
Just check that the actual IP:port of the filtered endpoints is
correct; using DeepEqual requires us to copy all the extra endpoint
fields (eg, ZoneHints, IsLocal) from endpoints to expectedEndpoints,
which just makes the test cases unnecessarily bigger.
2022-02-14 10:16:55 -05:00
Dan Winship
7240d87f79 topology_test.go: fix a test setup bug
The "node local endpoints, hints are ignored" test was not actually
enabling topology correctly, so it would have gotten the expected
result even if the code was wrong. (Which, FTR, it wasn't.)
2022-02-14 10:16:45 -05:00
Antonio Ojea
1c5d8cfdf7 fix flake test for ipvs graceful termination 2022-01-27 09:55:44 +01:00
cyclinder
50045b96bc kube-proxy ipvs: fix to prevent concurrent map read and map write
Signed-off-by: cyclinder <qifeng.guo@daocloud.io>
2022-01-26 11:12:56 +08:00
Kubernetes Prow Robot
3bd422dc76
Merge pull request #107293 from dims/jan-1-owners-cleanup
Cleanup OWNERS files - Jan 2021 Week 1
2022-01-13 10:30:30 -08:00
Kubernetes Prow Robot
68e64ba52e
Merge pull request #106453 from davidleitw/master
Fix typo
2022-01-11 17:13:23 -08:00
Kubernetes Prow Robot
10ded7501a
Merge pull request #107402 from anguslees/proxyzero
Reject proxy requests to 0.0.0.0 as well
2022-01-10 13:34:36 -08:00
Davanum Srinivas
9682b7248f
OWNERS cleanup - Jan 2021 Week 1
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-01-10 08:14:29 -05:00
Nikhil Sharma
c58fec6ccf removed unnecessary log line 2022-01-09 11:48:03 +05:30
Quan Tian
6ce612ef65 kube-proxy: fix duplicate port opening
When nodePortAddresses is not specified for kube-proxy, it tried to open
the node port for a NodePort service twice, triggered by IPv4ZeroCIDR
and IPv6ZeroCIDR separately. The first attempt would succeed and the
second one would always generate an error log like below:

"listen tcp4 :30522: bind: address already in use"

This patch fixes it by ensuring nodeAddresses of a proxier only contain
the addresses for its IP family.
2022-01-08 02:35:35 +08:00
Angus Lees
05cc0fb1df Reject proxy requests to 0.0.0.0 as well 2022-01-07 17:42:54 +11:00
cyclinder
97bd6e977d kube-proxy should log the payload when iptables-restore fails
Signed-off-by: cyclinder <qifeng.guo@daocloud.io>
2021-12-23 09:50:56 +08:00
Kubernetes Prow Robot
030c3fbd58
Merge pull request #106936 from sbangari/windowsserviceflappingfix
Skip creating HNS loadbalancer with empty endpoints
2021-12-10 22:41:57 -08:00
Sravanth Bangari
26be8d6890 Skip creating HNS loadbalancer with empty endpoints 2021-12-09 20:03:21 -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
Kubernetes Prow Robot
f356ae4ad9
Merge pull request #101719 from SergeyKanzhelev/removeReallyCrashForTesting
Remove ReallyCrashForTesting and cleaned up some references to Handle…
2021-12-07 23:39:45 -08:00
Sergey Kanzhelev
a11453efbc remove ReallyCrashForTesting and cleaned up some references to HandleCrash behavior 2021-11-29 20:00:10 +00:00
Amim Knabben
8b37bfec8e Enabling kube-proxy metrics on windows kernel mode 2021-11-21 21:23:55 -03:00
Rob Scott
1983f41065
Updating kube-proxy to ignore unready endpoints for Topology Hints 2021-11-18 14:04:44 -08:00
davidleitw
4944135dc2
Fix typo 2021-11-16 20:59:21 +08:00
Kubernetes Prow Robot
67a352e85f
Merge pull request #101429 from Nordix/issues-93858
Kube-proxy/ipvs; Use go "net" lib to get nodeIPs
2021-11-15 11:26:48 -08:00
Lars Ekman
9f37096c38 Kube-proxy/ipvs; Use go "net" lib to get nodeIPs
The nodeIPs to be used for nodePorts were collected using
netlink which was unnecessary complex and caused se #93858
2021-11-13 15:07:47 +01: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
Quan Tian
95a706ba7c Remove redundant forwarding rule in filter table 2021-11-11 10:27:53 +08:00
Dan Winship
a4e6d2f6fa proxy/iptables: add a unit test for the comment elision code 2021-11-10 09:08:02 -05:00
Dan Winship
8ef1255cdd proxy/iptables: Abstract out code for writing service-chain-to-endpoint-chain rules
The same code appeared twice, once for the SVC chain and once for the
XLB chain, with the only difference being that the XLB version had
more verbose comments.
2021-11-09 20:59:33 -05:00
Dan Winship
4c64008181 proxy/iptables: Abstract out shared OpenLocalPort code
Also, in the NodePort code, fix it to properly take advantage of the
fact that GetNodeAddresses() guarantees that if it returns a
"match-all" CIDR, then it doesn't return anything else. That also
makes it unnecessary to loop over the node addresses twice.
2021-11-09 20:59:30 -05:00
Dan Winship
9cd0552ddd proxy/iptables: Remove unnecessary /32 and /128 in iptables rules
If you pass just an IP address to "-s" or "-d", the iptables command
will fill in the correct mask automatically.

Originally, the proxier was just hardcoding "/32" for all of these,
which was unnecessary but simple. But when IPv6 support was added, the
code was made more complicated to deal with the fact that the "/32"
needed to be "/128" in the IPv6 case, so it would parse the IPs to
figure out which family they were, which in turn involved adding some
checks in case the parsing fails (even though that "can't happen" and
the old code didn't check for invalid IPs, even though that would
break the iptables-restore if there had been any).

Anyway, all of that is unnecessary because we can just pass the IP
strings to iptables directly rather than parsing and unparsing them
first.

(The diff to proxier_test.go is just deleting "/32" everywhere.)
2021-11-09 09:32:50 -05:00
Dan Winship
62672d06e6 proxy/iptables: fix a bug in node address error handling
If GetNodeAddresses() fails (eg, because you passed the wrong CIDR to
`--nodeport-addresses`), then any NodePort services would end up with
only half a set of iptables rules. Fix it to just not output the
NodePort-specific parts in that case (in addition to logging an error
about the GetNodeAddresses() failure).
2021-11-09 09:32:50 -05:00
Dan Winship
ab67a942ca proxy/iptables, proxy/ipvs: Remove an unnecessary check
The iptables and ipvs proxiers both had a check that none of the
elements of svcInfo.LoadBalancerIPStrings() were "", but that was
already guaranteed by the svcInfo code. Drop the unnecessary checks
and remove a level of indentation.
2021-11-09 09:32:50 -05:00
Tim Hockin
731dc8cf74
Fix regression in kube-proxy (#106214)
* Fix regression in kube-proxy

Don't use a prepend() - that allocates.  Instead, make Write() take
either strings or slices (I wish we could express that better).

* WIP: switch to intf

* WIP: less appends

* tests and ipvs
2021-11-08 15:14:49 -08:00
Kubernetes Prow Robot
0940dd6fc4
Merge pull request #106163 from aojea/conntrack_readiness
kube-proxy consider endpoint readiness to delete UDP stale conntrack entries
2021-11-08 13:11:44 -08:00
Tim Hockin
f662170ff7 kube-proxy: make iptables buffer-writing cleaner 2021-11-05 12:28:19 -07:00
Tim Hockin
f558554ce0 kube-proxy: minor cleanup
Get rid of overlapping helper functions.
2021-11-05 12:28:19 -07:00
Antonio Ojea
909925b492 kube-proxy: fix stale detection logic
The logic to detect stale endpoints was not assuming the endpoint
readiness.

We can have stale entries on UDP services for 2 reasons:
- an endpoint was receiving traffic and is removed or replaced
- a service was receiving traffic but not forwarding it, and starts
to forward it.

Add an e2e test to cover the regression
2021-11-05 20:14:56 +01:00
Dan Winship
229ae58520 proxy/iptables: fix all-vs-ready endpoints a bit
Filter the allEndpoints list into readyEndpoints sooner, and set
"hasEndpoints" based (mostly) on readyEndpoints, not allEndpoints (so
that, eg, we correctly generate REJECT rules for services with no
_functioning_ endpoints, even if they have unusable terminating
endpoints).

Also, write out the endpoint chains at the top of the loop when we
iterate the endpoints for the first time, rather than copying some of
the data to another set of variables and then writing them out later.
And don't write out endpoint chains that won't be used

Also, generate affinity rules only for readyEndpoints rather than
allEndpoints, so affinity gets broken correctly when an endpoint
becomes unready.
2021-11-04 16:32:08 -04:00
Dan Winship
3679639cf1 proxy/iptables: Remove a no-op check
There was code to deal with endpoints that have invalid/empty IP
addresses, but EndpointSlice validation already ensures that these
can't exist.
2021-11-04 16:32:08 -04:00
Dan Winship
6ab3dc6875 proxy/iptables: Add more stuff to the unit test
The external traffic policy terminating endpoints test was testing
LoadBalancer functionality against a NodePort service with no
nodePorts (or loadBalancer IPs). It managed to test what it wanted to
test, but it's kind of dubious (and we probably _shouldn't_ have been
generating the rules it was looking for since there was no way to
actually reach the XLB chains). So fix that.

Also make the terminating endpoints test use session affinity, to add
more testing for that. Also, remove the multiple copies of the same
identical Service that is used for all of the test cases in that test.

Also add a "Cluster traffic policy and no source ranges" test to
TestOverallIPTablesRulesWithMultipleServices since we weren't really
testing either of those.

Also add a test of --masquerade-all.
2021-11-04 16:32:08 -04:00
Dan Winship
22a951c096 proxy/iptables: Fix TestOnlyLocalNodePortsNoClusterCIDR
The test got broken to not actually use "no cluster CIDR" when
LocalDetector was implemented (and the old version of the unit test
didn't check enough to actually notice this).
2021-11-04 16:32:08 -04:00
Dan Winship
799c222c84 proxy/iptables: test that we create a consistent set of iptables rules 2021-11-04 16:32:08 -04:00
Dan Winship
9403bfb178 proxy/iptables: Misc improvements to unit test
The original tests here were very shy about looking at the iptables
output, and just relied on checks like "make sure there's a jump to
table X that also includes string Y somewhere in it" and stuff like
that. Whereas the newer tests were just like, "eh, here's a wall of
text, make sure the iptables output is exactly that". Although the
latter looks messier in the code, it's more precise, and it's easier
to update correctly when you change the rules. So just make all of the
tests do a check on the full iptables output.

(Note that I didn't double-check any of the output; I'm just assuming
that the output of the current iptables proxy code is actually
correct...)

Also, don't hardcode the expected number of rules in the metrics
tests, so that there's one less thing to adjust when rules change.

Also, use t.Run() in one place to get more precise errors on failure.
2021-11-04 16:32:06 -04:00
Dan Winship
a1a12ca1da proxy/iptables: Improve the sorting logic in TestOverallIPTablesRulesWithMultipleServices
The test was sorting the iptables output so as to not depend on the
order that services get processed in, but this meant it wasn't
checking the relative ordering of rules (and in fact, the ordering of
the rules in the "expected" string was wrong, in a way that would
break things if the rules had actually been generated in that order).

Add a more complicated sorting function that sorts services
alphabetically while preserving the ordering of rules within each
service.
2021-11-04 16:31:16 -04:00
Dan Winship
08680192fb proxy/iptables: Fix sync_proxy_rules_iptables_total metric
It was counting the number of lines including the "COMMIT" line at the
end, so it was off by one.
2021-11-04 16:30:12 -04:00
Shivanshu Raj Shrivastava
d3350f45e5
Migrated proxier_health.go , proxier.go to structured logging (#105767)
* fixed improperly migrated logs

* Update pkg/proxy/winkernel/proxier.go

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

Co-authored-by: Marek Siarkowicz <marek.siarkowicz@protonmail.com>
2021-10-21 10:17:48 -07:00
Shivanshu Raj Shrivastava
86aed49a18
Migrated ipvs/proxier.go(remaining) to structured logging (#105770)
* fixed improperly migrated logs

* fixed improperly migrated logs

* add
2021-10-21 08:41:57 -07:00
Shivanshu Raj Shrivastava
81636f2158
Fixed improperly migrated logs (#105763)
* fixed improperly migrated logs

* small fixes

* small fix

* Update pkg/proxy/iptables/proxier.go

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

* Update pkg/proxy/healthcheck/service_health.go

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

* Update pkg/proxy/iptables/proxier.go

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

* Update pkg/proxy/iptables/proxier.go

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

* Update pkg/proxy/iptables/proxier.go

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

* Update pkg/proxy/iptables/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>

* Update pkg/proxy/winkernel/proxier.go

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

* Update pkg/proxy/winkernel/proxier.go

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

* Update pkg/proxy/winkernel/proxier.go

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

* Update pkg/proxy/winkernel/proxier.go

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

* Update pkg/proxy/winkernel/proxier.go

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

* Update pkg/proxy/winkernel/proxier.go

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

* Update pkg/proxy/winkernel/proxier.go

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

* Update pkg/proxy/winkernel/proxier.go

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

* Update pkg/proxy/winkernel/proxier.go

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

* Update pkg/proxy/winkernel/proxier.go

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

* Update pkg/proxy/winkernel/proxier.go

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

* Update pkg/proxy/winkernel/proxier.go

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

* refactoring

* refactoring

* refactoring

* reverted some files back to master

Co-authored-by: Marek Siarkowicz <marek.siarkowicz@protonmail.com>
2021-10-20 03:55:58 -07: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
cyclinder
dd2d2ea7a7 revise kubeProxy filed as part of the kubeadm configuration
Signed-off-by: cyclinder <qifeng.guo@daocloud.io>
2021-10-20 10:32:29 +08:00
Shivanshu Raj Shrivastava
7d9a6d1de6
Migrated pkg/proxy/ipvs to structured logging (#104932)
* migrated ipset.go

* migrated graceful_termination.go

* fixed vstring

* fixed ip set entry, made it consistent

* fixed rs logging

* resolving review comments for key graceful_termination.go

* refactoring ipset.go

* included review changes
2021-10-14 09:47:29 -07:00
Shivanshu Raj Shrivastava
daf5af2917
Migrated pkg/proxy to structured logging (#104891)
* migrated service.go to structured logging

* fixing capital letter in starting

* migrated topology.go

* migrated endpointslicecache.go

* migrated endpoints.go

* nit typo

* nit plural to singular

* fixed format

* code formatting

* resolving review comment for key ipFamily

* resolving review comment for key endpoints.go

* code formating

* Converted Warningf to ErrorS, wherever applicable

* included review changes

* included review changes
2021-10-14 09:47:17 -07:00
Kubernetes Prow Robot
b6c01adcee
Merge pull request #105455 from shivanshu1333/patch-1
Update README.md
2021-10-06 18:45:46 -07:00
Kubernetes Prow Robot
2358c8ae5b
Merge pull request #105144 from umangachapagain/fix-logs
remove format specifiers from structured logs
2021-10-04 14:12:51 -07:00
Shivanshu Raj Shrivastava
49281ce819
Update README.md 2021-10-04 21:14:58 +05:30
elweb9858
365c5e5687 Removing elweb9858 from winkernel kube-proxy approver+reviewer lists 2021-09-30 11:40:37 -07:00
Umanga Chapagain
e262278772
fix incorrect structured log patterns
proxy/winkernel/proxier.go was using format specifier with
structured logging pattern which is wrong. This commit removes
use of format specifiers to align with the pattern.

Signed-off-by: Umanga Chapagain <chapagainumanga@gmail.com>
2021-09-30 11:10:13 +05:30
Lars Ekman
4d6db6f1fc Clear initial UDP conntrack entries for loadBalancerIPs 2021-09-25 16:03:56 +02:00
Khaled Henidak (Kal)
a53e2eaeab
move IPv6DualStack feature to stable. (#104691)
* kube-proxy

* endpoints controller

* app: kube-controller-manager

* app: cloud-controller-manager

* kubelet

* app: api-server

* node utils + registry/strategy

* api: validation (comment removal)

* api:pod strategy (util pkg)

* api: docs

* core: integration testing

* kubeadm: change feature gate to GA

* service registry and rest stack

* move feature to GA

* generated
2021-09-24 16:30:22 -07:00
Khaled (Kal) Henidak
59dd238fd4 mute unnecessary logs 2021-09-23 20:52:18 +00:00
jyz0309
e9abf3dfc6 remove spew
Signed-off-by: jyz0309 <45495947@qq.com>

remove spew

Signed-off-by: jyz0309 <45495947@qq.com>

remove LogJson

Signed-off-by: jyz0309 <45495947@qq.com>

change name

Signed-off-by: jyz0309 <45495947@qq.com>

remove spew

Signed-off-by: jyz0309 <45495947@qq.com>
2021-09-23 17:20:34 +08:00
jyz0309
c0e0fae775 fix error
Signed-off-by: jyz0309 <45495947@qq.com>

use InfoS handle json

Signed-off-by: jyz0309 <45495947@qq.com>

remove import

Signed-off-by: jyz0309 <45495947@qq.com>

fix comment

Signed-off-by: jyz0309 <45495947@qq.com>
2021-09-23 17:15:18 +08:00
jyz0309
a0fd52b6e1 fix log error
Signed-off-by: jyz0309 <45495947@qq.com>

fix conflict

Signed-off-by: jyz0309 <45495947@qq.com>

format code

Signed-off-by: jyz0309 <45495947@qq.com>
2021-09-23 17:15:18 +08:00
Daniel Canter
ce52f70c66 Replace custom dualstack support logic in Windows Kube-proxy
Due to an incorrect version range definition in hcsshim for dualstack
support, the Windows kubeproxy had to define it's own version range logic
to check if dualstack was supported on the host. This was remedied in hcsshim
(https://github.com/microsoft/hcsshim/pull/1003) and this work has been vendored into
K8s as well (https://github.com/kubernetes/kubernetes/pull/104880). This
change simply makes use of the now correct version range to check if dualstack
is supported, and gets rid of the old custom logic.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
2021-09-22 13:07:38 -07:00
Kubernetes Prow Robot
acbeaf8b8e
Merge pull request #104944 from jyz0309/migrate-log
Migrate `cmd/proxy/{config, healthcheck, winkernel}` to structured logging
2021-09-20 15:02:37 -07:00
Pritish Samal
060f5b88d0
Migrate pkg/proxy/util to structured logging (#104908)
* Migrate to Structured Logs in `pkg/proxy/util`

* Minor fixes

* change key to cidr and remove namespace arg

* Update key from cidr to CIDR

Co-authored-by: JUN YANG <69306452+yangjunmyfm192085@users.noreply.github.com>

* Update key cidr to CIDR

Co-authored-by: JUN YANG <69306452+yangjunmyfm192085@users.noreply.github.com>

* Update key ip to IP

Co-authored-by: JUN YANG <69306452+yangjunmyfm192085@users.noreply.github.com>

* Update key ip to IP

Co-authored-by: JUN YANG <69306452+yangjunmyfm192085@users.noreply.github.com>

* Interchange svcNamespace and svcName

* Change first letter of all messages to capital

* Change key names in endpoints.go

* Change all keynames to lower bumby caps convention

Co-authored-by: JUN YANG <69306452+yangjunmyfm192085@users.noreply.github.com>
2021-09-20 13:54:35 -07:00
Kubernetes Prow Robot
353f0a5eab
Merge pull request #105095 from wojtek-t/migrate_clock_3
Unify towards k8s.io/utils/clock - part 3
2021-09-20 12:46:45 -07:00
jyz0309
5d32be4126 fix type check
Signed-off-by: jyz0309 <45495947@qq.com>
2021-09-20 19:42:15 +08:00
jyz0309
6344d6b26d rebuild msg and rename namespace
Signed-off-by: jyz0309 <45495947@qq.com>
2021-09-20 19:04:21 +08:00
Shivanshu Raj Shrivastava
bbd809cbd0
Fixing incorrectly migrated structured logs (#105122)
* added keys for structured logging

* used KObj
2021-09-19 12:28:08 -07:00
wojtekt
d9b08c611d Migrate to k8s.io/utils/clock 2021-09-17 15:19:08 +02:00
Kubernetes Prow Robot
cb2ea4bf7c
Merge pull request #101161 from rikatz/move-sysctl-util
Move node and networking related helpers from pkg/util to component helpers
2021-09-17 02:11:00 -07:00
Ricardo Pchevuzinske Katz
37d11bcdaf Move node and networking related helpers from pkg/util to component helpers
Signed-off-by: Ricardo Katz <rkatz@vmware.com>
2021-09-16 17:00:19 -03:00
Shivanshu Raj Shrivastava
f06ce08d63
Migrated pkg/proxy/winuserspace to structured logging (#105035)
* migrated roundrobin.go

* migrated proxysocket.go

* used KRef in service
2021-09-16 11:36:02 -07:00
jyz0309
615c69643b migrate to struct log for proxy
Signed-off-by: jyz0309 <45495947@qq.com>

remove useless str

Signed-off-by: jyz0309 <45495947@qq.com>

fix comment

Signed-off-by: jyz0309 <45495947@qq.com>

fix comment

Signed-off-by: jyz0309 <45495947@qq.com>
2021-09-16 18:01:22 +08:00
Alkaid
5449ce7c5c
Migrate cmd/proxy/app and pkg/proxy/meta_proxier to structured logging (#104928)
* migrate log

Signed-off-by: jyz0309 <45495947@qq.com>

* remove useless change

Signed-off-by: jyz0309 <45495947@qq.com>

fix comment

Signed-off-by: jyz0309 <45495947@qq.com>

fix comment

Signed-off-by: jyz0309 <45495947@qq.com>

* use nil to instead err

Signed-off-by: jyz0309 <45495947@qq.com>

* fix comment

Signed-off-by: jyz0309 <45495947@qq.com>

* remove useless change

Signed-off-by: jyz0309 <45495947@qq.com>

* resolve conflict

Signed-off-by: jyz0309 <45495947@qq.com>

* resolve conflict

Signed-off-by: jyz0309 <45495947@qq.com>

* fix comment

Signed-off-by: jyz0309 <45495947@qq.com>

* fix comment

Signed-off-by: jyz0309 <45495947@qq.com>

* fix comment

Signed-off-by: jyz0309 <45495947@qq.com>
2021-09-14 20:50:40 -07:00
Kubernetes Prow Robot
648559b63e
Merge pull request #104742 from khenidak/health-check-port
change health-check port to listen to node port addresses
2021-09-13 15:43:52 -07:00
Kubernetes Prow Robot
31befb684c
Merge pull request #104801 from danwinship/drop-endpoints-handler
Drop broken/no-op proxyconfig.EndpointsHandler implementations
2021-09-13 12:16:02 -07:00
Khaled (Kal) Henidak
acdf50fbed change proxiers to pass nodePortAddresses 2021-09-13 18:27:07 +00:00
Khaled (Kal) Henidak
784c31cca1 change health checkport to listen to node port addresses 2021-09-13 18:27:06 +00:00
Shivanshu Raj Shrivastava
4916b6cd74
Migrated pkg/proxy/userspace to structured logging (#104931)
* migrated roundrobin.go

* migrated proxysocket.go

* fixed typo

* code formatting
2021-09-13 10:46:18 -07: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
Kubernetes Prow Robot
a402f1753c
Merge pull request #104756 from tnqn/ipvs-sctp-masquerade
Fix client IP preservation for NodePort service with protocol SCTP
2021-09-09 15:34:56 -07:00
Quan Tian
9ee3ae748b Fix client IP preservation for NodePort service with protocol SCTP
The iptables rule that matches kubeNodePortLocalSetSCTP must be inserted
before the one matches kubeNodePortSetSCTP, otherwise all SCTP traffic
would be masqueraded regardless of whether its ExternalTrafficPolicy is
Local or not.

To cover the case in tests, the patch adds rule order validation to
checkIptables.
2021-09-06 18:54:35 +08:00
Kubernetes Prow Robot
d3621ae008
Merge pull request #101303 from wangyx1992/capatial-log-proxy
cleanup: fix errors in wrapped format and log capitalization in proxy
2021-09-03 10:01:50 -07:00
Kubernetes Prow Robot
571a3f6f2f
Merge pull request #103896 from july2993/read
Remove wrong comment
2021-09-02 21:27:49 -07: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
Lars Ekman
25453708ea Remove pkg/utils/slice from kube-proxy 2021-08-19 06:48:27 +02:00
Kubernetes Prow Robot
a779c58b16
Merge pull request #104330 from liggitt/defaulter-package
Change defaulter-gen input to package import path
2021-08-17 11:42:18 -07:00
Kubernetes Prow Robot
cbb5ea8210
Merge pull request #101399 from wangyx1992/error-punctuation
cleanup: fix errors ending with punctuation in proxy
2021-08-16 00:51:46 -07:00
Jordan Liggitt
87a4e082ac Change defaulter-gen input to package path 2021-08-14 11:00:18 -04:00
Antonio Ojea
a2a22903bc delete stale UDP conntrack entries for loadbalancer IPs 2021-07-29 17:35:07 +02:00
Jiahao Huang
ee1bec1e6a Remove wrong comment
It does not assume proxier.mu is held because it locks it at the first
line.
2021-07-25 14:19:11 +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
James Sturtevant
d5d9327351 Only use dualstack if the node and config supports it 2021-07-08 11:39:20 -07:00
Lars Ekman
b6b3a69284 Don't set sysctl net.ipv4.vs.conn_reuse_mode for kernels >=5.9 2021-07-08 09:41:12 +02:00
Kubernetes Prow Robot
8fb777efb0
Merge pull request #103451 from swetharepakula/ga-proxy-gates
Graduate EndpointSliceProxying and WindowsEndpointSliceProxying Gates
2021-07-07 18:09:13 -07:00
Swetha Repakula
0a42f7b989 Graduate EndpointSliceProxying and WindowsEndpointSliceProxying Gates 2021-07-07 13:33:30 -07:00
Akihiro Suda
192790c52f
kube-proxy: allow running in userns
Ignore an error during setting RLIMIT_NOFILE.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-07-07 14:23:31 +09:00
Andrew Sy Kim
28f3f36505
Promote the ServiceInternalTrafficPolicy field to Beta and on by default (#103462)
* pkg/features: promote the ServiceInternalTrafficPolicy field to Beta and on by default

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/api/service/testing: update Service test fixture functions to set internalTrafficPolicy=Cluster by default

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/apis/core/validation: add more Service validation tests for internalTrafficPolicy

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/registry/core/service/storage: fix failing Service REST storage tests to use internalTrafficPolicy: Cluster

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/registry/core/service/storage: add two test cases for Service REST TestServiceRegistryInternalTrafficPolicyClusterThenLocal and TestServiceRegistryInternalTrafficPolicyLocalThenCluster

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/registry/core/service: update strategy unit tests to expect default
internalTrafficPolicy=Cluster

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/proxy/ipvs: fix unit test Test_EndpointSliceReadyAndTerminatingLocal to use internalTrafficPolicy=Cluster

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/apis/core: update fuzzers to set Service internalTrafficPolicy field

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/api/service/testing: refactor Service test fixtures to use Tweak funcs

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-07-06 06:16:30 -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
7cd40e1885
Merge pull request #103116 from chenyw1990/reducekubeproxycpu
reduce cpu usage of kube-proxy with iptables mode
2021-07-05 15:13:38 -07:00
chenyw1990
1f24a198e7 reduce cpu usage of kube-proxy with iptables mode 2021-07-05 16:08:19 +08:00
Swetha Repakula
03b7a699c2 Kubeproxy uses V1 EndpointSlice 2021-06-30 18:41:57 -07:00
Kubernetes Prow Robot
1151dc1ee5
Merge pull request #103138 from sbangari/winDsrLoadBalancerServiceFix
Loadbalancer IngressIP policy should be configured as non-DSR to enable routing mesh by default
2021-06-28 23:26:51 -07:00
Kubernetes Prow Robot
db3a216fbb
Merge pull request #97238 from andrewsykim/kube-proxy-handle-terminating
kube-proxy handle terminating endpoints
2021-06-28 20:46:40 -07:00
wangyx1992
c85e567a3d cleanup: fix errors in wrapped format and log capitalization in proxy
Signed-off-by: wangyx1992 <wang.yixiang@zte.com.cn>
2021-06-28 04:39:15 +08:00
Sravanth Bangari
23ce7977b7 Loadbalancer IngressIP policy should be configured as non-DSR to enable routing mesh by default 2021-06-23 23:09:46 -07:00
jay vyas
dd5f67d23c Kube proxy for windows userspace, remove dns Mangling 2021-06-15 18:46:48 -04:00
Yuan-Junliang
2e06066bab Migrate kube-proxy to use v1 Event API 2021-06-13 18:57:52 +08:00
Jian Zeng
9109d928cd
test(proxy::config): deflake TestInitialSync
Signed-off-by: Jian Zeng <zengjian.zj@bytedance.com>
2021-06-11 23:00:45 +08:00
Kubernetes Prow Robot
e692207857
Merge pull request #102555 from wzshiming/fix/close-modules-file
Close the used modules file
2021-06-09 14:55:26 -07:00
Andrew Sy Kim
1010e6a9d9 proxier/ipvs: fix test cases where ready endpoints were not used
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 20:14:00 -04:00
Andrew Sy Kim
8eb7e81bc9 proxy/ipvs: add unit test Test_HealthCheckNodePortWhenTerminating for ensuring health check node port fails when all local endpoints are terminating
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:17:43 -04:00
Andrew Sy Kim
ed4fe07375 proxy/iptables: add unit test Test_HealthCheckNodePortWhenTerminating for ensuring health check node port fails when all local endpoints are terminating
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:17:43 -04:00
Andrew Sy Kim
14cc201b58 proxy: add test case in TestGetLocalEndpointIPs for when all endpoints are terminating
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:17:43 -04:00
Andrew Sy Kim
3e459997c8 proxy/ipvs: add a unit tests for when the ProxyTerminatingEndpoint feature gate is disabled
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:17:43 -04:00
Andrew Sy Kim
68ebd16a2c proxier/iptables: refactor terminating endpoints unit tests with test table and test for feature gate
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:17:43 -04:00
Andrew Sy Kim
f92265f654 proxier/ipvs: check feature gate ProxyTerminatingEndpoints
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:17:43 -04:00
Andrew Sy Kim
8c514cb232 proxier/iptables: check feature gate ProxyTerminatingEndpoints
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:17:43 -04:00
Andrew Sy Kim
cf9ccf5a8e proxier/ipvs: unit tests should specify Service ports
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:17:43 -04:00
Andrew Sy Kim
d82d851d89 proxier/iptables: include Service port in unit tests
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:17:43 -04:00
Andrew Sy Kim
4c8b190372 proxier/iptables: reuse the same variable for endpointchains for better memory consumption
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:17:43 -04:00
Andrew Sy Kim
55881093d8 proxier/ipvs: add ipvs unit tests for falling back to terminating
endpoints

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:17:43 -04:00
Andrew Sy Kim
9d4e24aa32 proxier/ipvs: fall back to ready terminating if no ready endpoint exists
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:15:40 -04:00
Andrew Sy Kim
b54c0568d8 proxier/iptables: add unit tests for falling back to terminating endpoints
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:15:40 -04:00
Andrew Sy Kim
732635fd4b proxier/iptables: fallback to terminating endpoints if there are no ready endpoints
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:15:40 -04:00
Andrew Sy Kim
be92fc83e2 proxier: simplify toplogy FilterLocalEndpoint function
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-06-04 15:15:40 -04: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
Shiming Zhang
506fabc9ab Close the used modules file 2021-06-03 15:50:21 +08:00
Kubernetes Prow Robot
61db6e05f1
Merge pull request #100558 from yangjunmyfm192085/run-test31
Optimize the structured Logging migration.
2021-06-01 20:54:37 -07:00
刁浩 10284789
580b557592 Log spelling formatting and a redundant conversion
Signed-off-by: 刁浩 10284789 <diao.hao@zte.com.cn>
2021-05-27 07:07:22 +00:00
Kubernetes Prow Robot
8039ffc50e
Merge pull request #101935 from arkbriar/kube-proxy/fix-checkout-changes-for-endpoint-slice-cache
kube-proxy: Fix EndpointSliceCache::getEndpointsMap for different endpoints with same IP
2021-05-25 19:39:20 -07:00
arkbriar
f9cb68a2b1 Fix EndpointSliceCache::getEndpointsMap for different endpoints with same IP 2021-05-24 19:00:58 +08:00
Kubernetes Prow Robot
1d38084930
Merge pull request #97796 from JornShen/proxier_ipvs_structured_logging
migrate proxy/ipvs/proxier.go logs to structured logging
2021-05-16 20:05:59 -07:00
jornshen
9c6637e231 migrate proxy/ipvs/proxier.go logs to structured logging 2021-05-17 10:02:22 +08:00
Kubernetes Prow Robot
24727b5215
Merge pull request #101690 from fenngwd/fix/ingress_ip_blank
Check IP of Ingress blank before append
2021-05-13 15:36:05 -07:00
dervoeti
a231e21e63 fixed wrong warning in kube-proxy regarding topology aware hints 2021-05-09 22:05:21 +02:00
Kubernetes Prow Robot
73c1b2e260
Merge pull request #101358 from sbangari/localendpointrefcount
Ref counting is only applicable to Remote endpoints
2021-05-04 18:21:26 -07:00
Weidong Feng
63f9b392b5 Check IP of Ingress blank before append 2021-05-01 18:54:35 +08:00
Antonio Ojea
c6d97ee156 kube-proxy copy node labels 2021-04-28 13:26:26 +02:00
Kubernetes Prow Robot
c83cd70e2e
Merge pull request #97713 from thinpark/ipvs.typo
[pkg/proxy/ipvs]: fix README.md typo
2021-04-23 06:10:02 -07:00
wangyx1992
6a0452e861 cleanup: fix errors ending with punctuation in proxy
Signed-off-by: wangyx1992 <wang.yixiang@zte.com.cn>
2021-04-23 10:58:37 +08:00
Sravanth Bangari
32b2cd26c7 Ref counting is only applicable to Remote endpoints 2021-04-21 22:11:02 -07:00
Surya Seetharaman
d3fe48e848 Kube-proxy: perf-enhancement: Reduce NAT table KUBE-SERVICES/NODEPORTS chain rules
The nat KUBE-SERVICES chain is called from OUTPUT and PREROUTING stages. In
clusters with large number of services, the nat-KUBE-SERVICES chain is the largest
chain with for eg: 33k rules. This patch aims to move the KubeMarkMasq rules from
the kubeServicesChain into the respective KUBE-SVC-* chains. This way during each
packet-rule matching we won't have to traverse the MASQ rules of all services which
get accumulated in the KUBE-SERVICES and/or KUBE-NODEPORTS chains. Since the
jump to KUBE-MARK-MASQ ultimately sets the 0x400 mark for nodeIP SNAT, it should not
matter whether the jump is made from KUBE-SERVICES or KUBE-SVC-* chains.

Specifically we change:

1) For ClusterIP svc, we move the KUBE-MARK-MASQ jump rule from KUBE-SERVICES
chain into KUBE-SVC-* chain.
2) For ExternalIP svc, we move the KUBE-MARK-MASQ jump rule in the case of
non-ServiceExternalTrafficPolicyTypeLocal from KUBE-SERVICES
chain into KUBE-SVC-* chain.
3) For NodePorts svc, we move the KUBE-MARK-MASQ jump rule in case of
non-ServiceExternalTrafficPolicyTypeLocal from KUBE-NODEPORTS chain to
KUBE-SVC-* chain.
4) For load-balancer svc, we don't change anything since it is already svc specific
due to creation of KUBE-FW-* chains per svc.

This would cut the rules per svc in KUBE-SERVICES and KUBE-NODEPORTS in half.
2021-04-21 16:41:03 +02:00
Surya Seetharaman
667e50abc8 Add TestOverallIPTablesRulesWithMultipleServices 2021-04-21 16:41:03 +02:00
Kubernetes Prow Robot
6a667de8d8
Merge pull request #99448 from JornShen/use_exist_utils_nets_replace_parseExcludedCIDRs
cleanup parseExcludedCIDRs
2021-04-17 19:32:36 -07:00
Kubernetes Prow Robot
d090d17cb5
Merge pull request #101023 from Nordix/ipvs-cleanup-localhost
Disable localhost:nodeport for proxy-mode=ipvs
2021-04-16 22:22:10 -07:00
Kubernetes Prow Robot
3fec9f9bc5
Merge pull request #100636 from andrewsykim/add-uablrek-ipvs-maintainer
ipvs: add uablrek to OWNERS
2021-04-16 06:52:22 -07:00
Lars Ekman
e030621e0a Disable loopback:nodeport for proxy-mode=ipvs 2021-04-16 08:37:47 +02:00
Kubernetes Prow Robot
34909133de
Merge pull request #100804 from aojea/topohints
Fix Topology Aware Hints support for Kube-Proxy
2021-04-12 01:48:00 -07:00
Kubernetes Prow Robot
eda1de301a
Merge pull request #100874 from lojies/proxyiptableslog
improve the readability of log
2021-04-10 19:04:37 -07:00
Kubernetes Prow Robot
ff2a3e1147
Merge pull request #100861 from aojea/kproxy_latency
fix kube-proxy latency metrics
2021-04-10 19:03:55 -07:00
Kubernetes Prow Robot
1cedfef5c6
Merge pull request #100728 from robscott/topology-auto
Updating Topology Aware Hints to support "Auto" value for annotation
2021-04-09 05:20:38 -07:00
Kubernetes Prow Robot
6c97da72f4
Merge pull request #100599 from masap/nodeport1
Fire an event when failing to open NodePort
2021-04-09 05:19:29 -07:00
Kubernetes Prow Robot
611a2d9d54
Merge pull request #100088 from yangjunmyfm192085/run-test27
Fix TestGetNodeAddresses function error.
2021-04-08 17:11:56 -07:00
Kubernetes Prow Robot
016d1c1072
Merge pull request #99278 from yangjunmyfm192085/run-test21
Fix incorrect use of  klog.ErrorS
2021-04-08 14:27:58 -07:00
Antonio Ojea
ef76be37de kube-proxy network programming latency on restarts
kube-proxy expose the metric network_programming_duration_seconds,
that is defined as the time it takes to program the network since
a a service or pod has changed. It uses an annotation on the endpoints
/endpointslices to calculate when the endpoint was created, however,
on restarts, kube-proxy process all the endpoints again, no matter
when those were generated, polluting the metrics.

To be safe, kube-proxy will estimate the latency only for those
endpoints that were generated after it started.
2021-04-07 19:19:02 +02:00
卢振兴10069964
98d4bdb5d7 improve the readability of log 2021-04-07 15:10:05 +08:00
Antonio Ojea
1e1c4c5ac9 add node handlers to the metaproxier 2021-04-05 02:05:18 +02:00
Masashi Honma
d43b8dbf4e Use simpler expressions for error messages
1. Do not describe port type in message because lp.String() already has the
information.

2. Remove duplicate error detail from event log.
Previous log is like this.

47s         Warning   listen tcp4 :30764: socket: too many open files   node/127.0.0.1   can't open port "nodePort for default/temp-svc:834" (:30764/tcp4), skipping it: listen tcp4 :30764: socket: too many open files
2021-04-01 09:13:45 +09:00
Masashi Honma
3266136c1d Fire an event when failing to open NodePort
[issue]
When creating a NodePort service with the kubectl create command, the NodePort
assignment may fail.

Failure to assign a NodePort can be simulated with the following malicious
command[1].

$ kubectl create service nodeport temp-svc --tcp=`python3 <<EOF
print("1", end="")
for i in range(2, 1026):
  print("," + str(i), end="")
EOF
`

The command succeeds and shows following output.

service/temp-svc created

The service has been successfully generated and can also be referenced with the
get command.

$ kubectl get svc
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)
temp-svc     NodePort    10.0.0.139   <none>        1:31335/TCP,2:32367/TCP,3:30263/TCP,(omitted),1023:31821/TCP,1024:32475/TCP,1025:30311/TCP   12s

The user does not recognize failure to assign a NodePort because
create/get/describe command does not show any error. This is the issue.

[solution]
Users can notice errors by looking at the kube-proxy logs, but it may be difficult to see the kube-proxy logs of all nodes.

E0327 08:50:10.216571  660960 proxier.go:1286] "can't open port, skipping this nodePort" err="listen tcp4 :30641: socket: too many open files" port="\"nodePort for default/temp-svc:744\" (:30641/tcp4)"
E0327 08:50:10.216611  660960 proxier.go:1286] "can't open port, skipping this nodePort" err="listen tcp4 :30827: socket: too many open files" port="\"nodePort for default/temp-svc:857\" (:30827/tcp4)"
...
E0327 08:50:10.217119  660960 proxier.go:1286] "can't open port, skipping this nodePort" err="listen tcp4 :32484: socket: too many open files" port="\"nodePort for default/temp-svc:805\" (:32484/tcp4)"
E0327 08:50:10.217293  660960 proxier.go:1612] "Failed to execute iptables-restore" err="pipe2: too many open files ()"
I0327 08:50:10.217341  660960 proxier.go:1615] "Closing local ports after iptables-restore failure"

So, this patch will fire an event when NodePort assignment fails.
In fact, when the externalIP assignment fails, it is also notified by event.

The event will be displayed like this.

$ kubectl get event
LAST SEEN   TYPE      REASON                                            OBJECT           MESSAGE
...
2s          Warning   listen tcp4 :31055: socket: too many open files   node/127.0.0.1   can't open "nodePort for default/temp-svc:901" (:31055/tcp4), skipping this nodePort: listen tcp4 :31055: socket: too many open files
2s          Warning   listen tcp4 :31422: socket: too many open files   node/127.0.0.1   can't open "nodePort for default/temp-svc:474" (:31422/tcp4), skipping this nodePort: listen tcp4 :31422: socket: too many open files
...

This PR fixes iptables and ipvs proxier.
Since userspace proxier does not seem to be affected by this issue, it is not fixed.

[1] Assume that fd limit is 1024(default).
$ ulimit -n
1024
2021-04-01 08:27:51 +09:00
Rob Scott
50b377fe4e
Updating Topology Aware Hints to support "Auto" value for annotation
Previously only "auto" was supported, a value that was inconsistent with
Kubernetes naming patterns.
2021-03-31 15:58:42 -07:00
Andrew Sy Kim
dec775bb7a ipvs: add uablrek to OWNERS
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-03-29 14:04:51 -04:00
JUN YANG
80b4277bff Optimize the structured Logging migration.
Signed-off-by: JUN YANG <yang.jun22@zte.com.cn>
2021-03-25 20:21:38 +08:00
jornshen
b1c6e70255 cleanup parseExcludedCIDRs 2021-03-23 17:15:43 +08:00
JunYang
923306b1ba Fix TestGetNodeAddresses function error.
Signed-off-by: JunYang <yang.jun22@zte.com.cn>
2021-03-10 23:33:57 +08:00
Kubernetes Prow Robot
b014610de3
Merge pull request #99958 from sbangari/winkubeproxylbservicefix
For LoadBalancer Service type don't create a HNS policy for empty or invalid external loadbalancer IP
2021-03-10 00:35:35 -08:00
Rob Scott
f07be06a19
Adding support for TopologyAwareHints to kube-proxy 2021-03-08 15:37:47 -08:00
Fangyuan Li
0621e90d31 Rename fields and methods for BaseServiceInfo
Fields:
1. rename onlyNodeLocalEndpoints to nodeLocalExternal;
2. rename onlyNodeLocalEndpointsForInternal to nodeLocalInternal;
Methods:
1. rename OnlyNodeLocalEndpoints to NodeLocalExternal;
2. rename OnlyNodeLocalEndpointsForInternal to NodeLocalInternal;
2021-03-07 16:52:59 -08:00
Fangyuan Li
7ed2f1d94d Implements Service Internal Traffic Policy
1. Add API definitions;
2. Add feature gate and drops the field when feature gate is not on;
3. Set default values for the field;
4. Add API Validation
5. add kube-proxy iptables and ipvs implementations
6. add tests
2021-03-07 16:52:59 -08:00
Swetha Repakula
108fd44f7c Graduate EndpointSlice feature gate to GA 2021-03-06 15:58:47 -08:00
Kubernetes Prow Robot
269d62d895
Merge pull request #97837 from JornShen/proxier_userspace_structured_logging
migrate proxy/userspace/proxier.go logs to structured logging
2021-03-05 13:25:42 -08:00
Kubernetes Prow Robot
70d732c7e7
Merge pull request #99653 from aojea/kproxymetrics
new kube-proxy iptables metric to expose then number of iptables rules
2021-03-05 10:00:34 -08:00
Antonio Ojea
654be57022 kube-proxy iptables expose number of rules metrics
add a new metric to kube-proxy iptables, so it exposes the number
of rules programmed in each iteration.
2021-03-05 10:00:38 +01:00
Swetha Repakula
6f5329d4c0 Remove EndpointSliceNodeName feature gate logic
- feature gate has graduated to GA and will always be enabled, so no
 longer need to check if enabled
2021-03-04 09:57:15 -08:00
Kubernetes Prow Robot
7c9841d586
Merge pull request #98985 from timyinshi/proxy
delete the extra word
2021-03-03 01:53:32 -08:00
Benjamin Elder
56e092e382 hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
JunYang
53056e88b6 Fix incorrect use of klog.ErrorS
Signed-off-by: JunYang <yang.jun22@zte.com.cn>
2021-02-21 14:55:23 +08:00
Kubernetes Prow Robot
4ef5d1402d
Merge pull request #99102 from justinsb/avoid_multiple_calls_to_done
proxy/config tests: avoid multiple calls to done
2021-02-18 20:28:24 -08:00
Kubernetes Prow Robot
6dc317a107
Merge pull request #98130 from JornShen/optimze_redundant_listenPortOpener
migrate to use k8s.io/util/net/port in kube-proxy
2021-02-18 10:02:51 -08:00
Justin SB
6ac76e184e proxy/config tests: avoid multiple calls to done
If the callback is called multiple times the wait group will be
over-decremented.
2021-02-15 15:23:21 -05:00
jornshen
dbe89a5683 migrate kube canary chain as const 2021-02-15 16:50:48 +08:00
jornshen
00e26e9785 clear pkg/proxy/port.go port_test.go file 2021-02-15 16:36:09 +08:00
jornshen
d8d6a0223b clear no use LocalPort in winkernel 2021-02-15 16:36:08 +08:00
jornshen
97a5a3d4d5 migrate to use k8s.io/util LocalPort and ListenPortOpener in ipvs.proxier 2021-02-15 16:36:08 +08:00
jornshen
e68e105102 migrate to use k8s.io/util LocalPort and ListenPortOpener in iptables.proxier 2021-02-15 16:36:06 +08:00
timyinshi
5242af9d2d
delete the extra word
Signed-off-by: timyinshi <shiguangyin@inspur.com>
2021-02-11 16:35:48 +08:00
Kubernetes Prow Robot
659b4dc4a8
Merge pull request #98305 from aojea/holdports
kube-proxy has to clear NodePort stale UDP entries
2021-02-10 23:36:16 -08:00
Antonio Ojea
ed21a0e16c kube-proxy: clear conntrack entries after rules are in place
Clear conntrack entries for UDP NodePorts,
this has to be done AFTER the iptables rules are programmed.
It can happen that traffic to the NodePort hits the host before
the iptables rules are programmed this will create an stale entry
in conntrack that will blackhole the traffic, so we need to
clear it ONLY when the service has endpoints.
2021-02-10 16:22:03 +01:00
Kubernetes Prow Robot
6b9379eae4
Merge pull request #98001 from JornShen/proxier_winkernel_structured_logging
migrate proxy/winkernel/proxier.go logs to structured logging
2021-02-09 23:47:12 -08:00
Kubernetes Prow Robot
c1b3797f4b
Merge pull request #97824 from hanlins/fix/97225/hc-rules
Explicitly add iptables rule to allow healthcheck nodeport
2021-02-04 15:54:52 -08:00
Hanlin Shi
4cd1eacbc1 Add rule to allow healthcheck nodeport traffic in filter table
1. For iptables mode, add KUBE-NODEPORTS chain in filter table. Add
   rules to allow healthcheck node port traffic.
2. For ipvs mode, add KUBE-NODE-PORT chain in filter table. Add
   KUBE-HEALTH-CHECK-NODE-PORT ipset to allow traffic to healthcheck
   node port.
2021-02-03 15:20:10 +00:00
Sravanth Bangari
04eced5c67 For LoadBalancer Service type don't create a HNS policy for empty or invalid external loadbalancer IP 2021-01-31 11:56:30 -08:00
jornshen
e3d068870d migrate proxy/userspace/proxier.go logs to structured logging 2021-01-30 10:21:51 +08:00
Kubernetes Prow Robot
e89e7b4ed1
Merge pull request #98083 from JornShen/optimize_proxier_duplicate_localaddrset
optimize proxier duplicate localaddrset
2021-01-29 01:21:40 -08:00
jornshen
3f506cadb0 optimize proxier duplicate localaddrset 2021-01-29 10:52:01 +08:00
Kubernetes Prow Robot
97076f6647
Merge pull request #98297 from JornShen/replace_ipvs_proxier_protocal_str
use exist const to replace ipvs/proxier.go tcp,udp,sctp str
2021-01-28 14:41:52 -08:00
Jordan Liggitt
ce553e1b68 Resolve IP addresses of host-only in filtered dialer 2021-01-26 12:00:53 -05:00
Kubernetes Prow Robot
b557633c3f
Merge pull request #98249 from JornShen/optimize_writeline_writeBytesLine
Optimize writeline and writeBytesLine in proxier.go
2021-01-22 23:45:39 -08:00
jornshen
249996e62f use exist const to replace ipvs/proxier.go tcp,udp,sctp 2021-01-22 14:52:00 +08:00
jornshen
761473cd44 add ut for utils WriteLine WriteBytesLine 2021-01-21 10:51:54 +08:00
jornshen
3783821553 move the redundant writeline writeBytesLine to proxy/util/util.go 2021-01-21 10:51:39 +08:00
Kubernetes Prow Robot
0c91285ea6
Merge pull request #97941 from JornShen/proxier_winuserspace_structured_logging
migrate proxy/winuserspace/proxier.go logs to structured logging
2021-01-20 17:51:00 -08:00
jornshen
f3b9e8b105 migrate proxy/winkernel/proxier.go logs to structured logging 2021-01-18 09:35:51 +08:00
Kubernetes Prow Robot
857c06eb49
Merge pull request #98043 from JornShen/migrate_string_overlay_as_const
migrate winkernel network type string "overlay" as const
2021-01-14 20:43:51 -08:00
jornshen
dff2da8cbc migrate winkernel network type string overlay as const 2021-01-14 16:38:02 +08:00
Kubernetes Prow Robot
5c7ee30eaa
Merge pull request #94902 from cmluciano/cml/proxyvaltesting
proxy: Restructure config validation tests to check errors
2021-01-13 10:18:36 -08:00
Kubernetes Prow Robot
eb08f36c7d
Merge pull request #96371 from andrewsykim/kube-proxy-terminating
kube-proxy: track serving/terminating conditions in endpoints cache
2021-01-11 18:38:25 -08:00
jornshen
a5a5fef039 migrate proxy/winuserspace/proxier.go logs to structured logging 2021-01-12 10:31:31 +08:00
Kubernetes Prow Robot
5e22f7fead
Merge pull request #92938 from DataDog/lbernail/CVE-2020-8558
Do not set sysctlRouteLocalnet (CVE-2020-8558)
2021-01-11 17:38:24 -08:00
Andrew Sy Kim
a11abb5475 kube-proxy: ipvs proxy should ignore endpoints with condition ready=false
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-01-11 16:27:38 -05:00
Andrew Sy Kim
9c096292cc kube-proxy: iptables proxy should ignore endpoints with condition ready=false
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-01-11 16:27:38 -05:00
Andrew Sy Kim
1acdfb4e7c kube-proxyy: update winkernel proxier to read 'ready', 'serving' and 'terminating' conditions
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-01-11 16:17:58 -05:00
Andrew Sy Kim
a7333e1a3e kube-proxy: add endpointslice cache unit tests for terminating endpoints
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-01-11 16:17:58 -05:00
Andrew Sy Kim
e5f9b80023 kube-proxy: health check server should only check ready endpoints
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-01-11 16:17:58 -05:00
Andrew Sy Kim
55cb453a3c kube-proxy: update internal endpoints map with 'serving' and 'terminating' condition from EndpointSlice
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-01-11 16:17:58 -05:00
Laurent Bernaille
15439148da
Do not set sysctlRouteLocalnet (CVE-2020-8558)
Signed-off-by: Laurent Bernaille <laurent.bernaille@datadoghq.com>
2021-01-11 11:41:32 +01:00
jornshen
5af5a2ac7d migrate proxy.UpdateServiceMap to be a method of ServiceMap 2021-01-11 11:07:30 +08:00
Kubernetes Prow Robot
5150d2f839
Merge pull request #97716 from chengzhycn/syncEndpoint-error-return
proxy/ipvs: return non-nil error when there is no matched IPVS servic…
2021-01-07 12:44:54 -08:00
Kubernetes Prow Robot
466e2e3751
Merge pull request #97678 from JornShen/proxier_iptables_structured_logging
migrate proxy/iptables/proxier.go logs to structured logging
2021-01-07 11:51:05 -08:00
chengzhycn
c6c74f2a5d proxy/ipvs: return non-nil error when there is no matched IPVS service in syncEndpoint
Signed-off-by: chengzhycn <chengzhycn@gmail.com>
2021-01-07 10:49:04 +08:00
jornshen
07990e44bf migrate proxy/iptables/proxier.go logs to structured logging 2021-01-07 10:48:01 +08:00
Zhou Peng
0ca17c62d2 [pkg/proxy/ipvs]: fix README.md typo
Signed-off-by: Zhou Peng <p@ctriple.cn>
2021-01-05 14:04:10 +08:00
Kubernetes Prow Robot
77abaabf3a
Merge pull request #97677 from chengzhycn/proxy-error-log
fix incorrect dev name in log when finding link by name returns error
2021-01-04 19:33:57 -08:00
chengzhycn
5bd2b6877d fix incorrect dev name in log when finding link by name returns error
Signed-off-by: chengzhycn <chengzhycn@gmail.com>
2021-01-04 16:34:02 +08:00
maao
d001b9b72a remove --cleanup-ipvs flag of kube-proxy
Signed-off-by: maao <maao420691301@gmail.com>
2020-12-31 11:29:38 +08:00
Kubernetes Prow Robot
6aae473318
Merge pull request #96830 from tnqn/ipvs-restore-commands
Fix duplicate chains in iptables-restore input
2020-12-08 20:03:34 -08:00
Kubernetes Prow Robot
c9dfd5829b
Merge pull request #96728 from jeremyje/dontpanic
Fail instead of panic when HNS network cannot be created in test.
2020-12-08 18:36:14 -08:00
Kubernetes Prow Robot
d2662b9842
Merge pull request #96488 from basantsa1989/kproxy_cleanup
Kube-proxy cleanup: Changing FilterIncorrectIP/CIDR functions to MapIPsToIPFamily that returns a map
2020-12-08 17:28:52 -08:00
Jeremy Edwards
7f972840ca Fail instead of panic when HNS network cannot be created in test. 2020-12-02 07:01:27 +00:00
Quan Tian
9bf96b84c4 Fix duplicate chains in iptables-restore input
When running in ipvs mode, kube-proxy generated wrong iptables-restore
input because the chain names are hardcoded.

It also fixed a typo in method name.
2020-11-24 15:13:23 +08:00
Antonio Ojea
120472032c kube-proxy: treat ExternalIPs as ClusterIP
Currently kube-proxy treat ExternalIPs differently depending on:
- the traffic origin
- if the ExternalIP is present or not in the system.

It also depends on the CNI implementation to
discriminate between local and non-local traffic.

Since the ExternalIP belongs to a Service, we can avoid the roundtrip
of sending outside the traffic originated in the cluster.

Also, we leverage the new LocalTrafficDetector to detect the local
traffic and not rely on the CNI implementations for this.
2020-11-22 00:54:33 +01:00
Basant Amarkhed
293d4b7c48 Avoiding double parsing of ip/cidr strings and logging bad ips/cidrs 2020-11-20 22:22:55 +00:00
Basant Amarkhed
f11c4e9c8c Testcases for MapCIDRsByIPFamily 2020-11-17 07:35:50 +00:00
Basant Amarkhed
707073d2f9 Fixup #1 addressing review comments 2020-11-17 07:13:51 +00:00
Basant Amarkhed
09d966c8cc Adding service.go changes after merge 2020-11-14 01:09:46 +00:00
Basant Amarkhed
8fb895f3f1 Updating after merging with a conflicting commit 2020-11-14 01:09:46 +00:00
Kubernetes Prow Robot
94b17881fc
Merge pull request #96454 from Sh4d1/revert_92312
Revert "Merge pull request #92312 from Sh4d1/kep_1860"
2020-11-12 16:03:24 -08:00
Kubernetes Prow Robot
765d949bfc
Merge pull request #96440 from robscott/endpointslice-pre-ga
Adding NodeName to EndpointSlice API, deprecation updates
2020-11-12 16:03:13 -08:00
Rob Scott
84e4b30a3e
Updates related to PR feedback
- Remove feature gate consideration from EndpointSlice validation
- Deprecate topology field, note that it will be removed in future
release
- Update kube-proxy to check for NodeName if feature gate is enabled
- Add comments indicating the feature gates that can be used to enable
alpha API fields
- Add comments explaining use of deprecated address type in tests
2020-11-12 12:30:50 -08:00
Sravanth Bangari
6c68ca5a9e Choosing the right source VIP for local endpoints 2020-11-11 23:29:07 -08:00
Rob Scott
506861c0a0
Removing "IP" from supported EndpointSlice address types in kube-proxy 2020-11-11 16:50:45 -08:00
Christopher M. Luciano
a036577e2c
proxy: Restructure config validation tests to check errors
The tests for most functions have also been revised to check the errors
explicitly upon validating. This will properly catch occasions
where we should be returning multiple errors if more error occurs or
if just one block is failing.

Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>
2020-11-11 14:38:11 -05:00
Patrik Cyvoct
d29665cc17
Revert "Merge pull request #92312 from Sh4d1/kep_1860"
This reverts commit ef16faf409, reversing
changes made to 2343b8a68b.
2020-11-11 10:26:53 +01:00
Kubernetes Prow Robot
ef16faf409
Merge pull request #92312 from Sh4d1/kep_1860
Make Kubernetes aware of the LoadBalancer behaviour
2020-11-08 23:34:24 -08:00
Kubernetes Prow Robot
2343b8a68b
Merge pull request #95872 from 22dm/kube-proxy-comment-fix
Fix the kube-proxy document
2020-11-08 19:23:37 -08:00
Patrik Cyvoct
20fc86df25
fix defaulting
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2020-11-07 10:00:59 +01:00
Patrik Cyvoct
0768b45e7b
add nil case in proxy
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2020-11-07 10:00:58 +01:00