Commit Graph

1693 Commits

Author SHA1 Message Date
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
Patrik Cyvoct
11b97e9ef8
fix tests
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2020-11-07 10:00:55 +01:00
Patrik Cyvoct
540901779c
fix reviews
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2020-11-07 10:00:53 +01:00
Patrik Cyvoct
af7494e896
Update generated
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2020-11-07 10:00:52 +01:00
Patrik Cyvoct
7bdf2af648
fix review
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2020-11-07 10:00:51 +01:00
Patrik Cyvoct
88330eafef
fix typo
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2020-11-07 10:00:50 +01:00
Patrik Cyvoct
0153b96ab8
fix review
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2020-11-07 10:00:27 +01:00
Patrik Cyvoct
d562b6924a
Add tests
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2020-11-07 09:59:59 +01:00
Patrik Cyvoct
47ae7cbf52
Add route type field to loadbalancer status ingress
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2020-11-07 09:59:58 +01:00
Kubernetes Prow Robot
48a2bca893
Merge pull request #96251 from ravens/nodeport_udp_conntrack_fix
Correctly fix clearing conntrack entry on endpoint changes (nodeport)
2020-11-06 14:25:37 -08:00
Kubernetes Prow Robot
f1a3e4dcce
Merge pull request #95036 from cmluciano/cml/validateproxycidrs
proxy: validate each CIDR config seperately and check for errors
2020-11-05 13:12:52 -08:00
Kubernetes Prow Robot
0451848d64
Merge pull request #95787 from qingsenLi/k8s201022-format
format incorrectAddresses in klog
2020-11-05 11:50:33 -08:00
Christopher M. Luciano
705ba7b4bc
proxy: validate each CIDR config seperately and check for errors
This commit revises validateProxyNodePortAddress and
validateExcludeCIDRS to report on the exact CIDR that is
invalid within the array of strings. Previously we would just return
the whole block of addresses and now we identify the exact address
within the block to eliminate confusion. I also removed the break from
validateProxyNodeAddress so that we can report on all addresses that
may not be valid.

The tests for each function have also been revised to check the errors
explicitly upon validating. This also will properly catch occasions
where we should be returning multiple errors if more than one CIDR is invalid.

Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>
2020-11-05 13:56:39 -05:00
Yan Grunenberger
fdee7b2faa Correctly fix clearing conntrack entry on endpoint changes (nodeport)
A previous PR (#71573) intended to clear conntrack entry on endpoint
changes when using nodeport by introducing a dedicated function to
remove the stale conntrack entry on the node port and allow traffic to
resume. By doing so, it has introduced a nodeport specific bug where the
conntrack entries related to the ClusterIP does not get clean if
endpoint is changed (issue #96174). We fix by doing ClusterIP cleanup in
all cases.
2020-11-05 09:45:17 +01:00
elweb9858
1bcddb0747 Implementing ExternalTrafficPolicy: local in winkernel kube-proxy via DSR 2020-10-30 15:28:47 -07:00
Khaled Henidak (Kal)
6675eba3ef
dual stack services (#91824)
* api: structure change

* api: defaulting, conversion, and validation

* [FIX] validation: auto remove second ip/family when service changes to SingleStack

* [FIX] api: defaulting, conversion, and validation

* api-server: clusterIPs alloc, printers, storage and strategy

* [FIX] clusterIPs default on read

* alloc: auto remove second ip/family when service changes to SingleStack

* api-server: repair loop handling for clusterIPs

* api-server: force kubernetes default service into single stack

* api-server: tie dualstack feature flag with endpoint feature flag

* controller-manager: feature flag, endpoint, and endpointSlice controllers handling multi family service

* [FIX] controller-manager: feature flag, endpoint, and endpointSlicecontrollers handling multi family service

* kube-proxy: feature-flag, utils, proxier, and meta proxier

* [FIX] kubeproxy: call both proxier at the same time

* kubenet: remove forced pod IP sorting

* kubectl: modify describe to include ClusterIPs, IPFamilies, and IPFamilyPolicy

* e2e: fix tests that depends on IPFamily field AND add dual stack tests

* e2e: fix expected error message for ClusterIP immutability

* add integration tests for dualstack

the third phase of dual stack is a very complex change in the API,
basically it introduces Dual Stack services. Main changes are:

- It pluralizes the Service IPFamily field to IPFamilies,
and removes the singular field.
- It introduces a new field IPFamilyPolicyType that can take
3 values to express the "dual-stack(mad)ness" of the cluster:
SingleStack, PreferDualStack and RequireDualStack
- It pluralizes ClusterIP to ClusterIPs.

The goal is to add coverage to the services API operations,
taking into account the 6 different modes a cluster can have:

- single stack: IP4 or IPv6 (as of today)
- dual stack: IPv4 only, IPv6 only, IPv4 - IPv6, IPv6 - IPv4

* [FIX] add integration tests for dualstack

* generated data

* generated files

Co-authored-by: Antonio Ojea <aojea@redhat.com>
2020-10-26 13:15:59 -07:00
Kubernetes Prow Robot
bdde4fb8f5
Merge pull request #93040 from cmluciano/cml/ipvsschedmodules
ipvs: ensure selected scheduler kernel modules are loaded
2020-10-26 10:25:17 -07:00
liuhongyu
d1525ec808 Fix the kube-proxy comment so that the document can be generated correctly 2020-10-26 23:13:50 +08:00
Christopher M. Luciano
51ed242194
ipvs: check for existence of scheduler module and fail if not found
Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>
2020-10-23 17:17:44 -04:00
Kubernetes Prow Robot
766ae2b81b
Merge pull request #95252 from tssurya/shrink-input-chain
Kube-proxy: Perf-fix: Shrink INPUT chain
2020-10-22 22:16:02 -07:00
qingsenLi
9ad39c9eda format incorrectAddresses in klog 2020-10-22 17:26:29 +08:00
Surya Seetharaman
477b14b3c4 Kube-proxy: Perf-fix: Shrink INPUT chain
In #56164, we had split the reject rules for non-ep existing services
into KUBE-EXTERNAL-SERVICES chain in order to avoid calling KUBE-SERVICES
from INPUT. However in #74394 KUBE-SERVICES was re-added into INPUT.

As noted in #56164, kernel is sensitive to the size of INPUT chain. This
patch refrains from calling the KUBE-SERVICES chain from INPUT and FORWARD,
instead adds the lb reject rule to the KUBE-EXTERNAL-SERVICES chain which will be
called from INPUT and FORWARD.
2020-10-19 11:26:04 +02:00
Antonio Ojea
880baa9f6f kube-proxy: log stale services operations 2020-10-19 09:35:34 +02:00
Lion-Wei
1f7ea16560 kube-proxy ensure KUBE-MARK-DROP exist but not modify their rules 2020-10-16 14:52:07 +08:00
wojtekt
6e4aa0f27d Fix reporting network_programming_latency metrics in kube-proxy 2020-10-07 20:57:14 +02:00
John Howard
b898266cb1 Fix documentation on EndpointSliceCache map
This is not storing by slice name, it is IP. This can be seen from the
code and tests.
2020-10-06 10:24:09 -07:00
Christopher M. Luciano
601c5150ca
proxy: Add tests for kube-proxy config defaulting
Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>
2020-10-02 12:39:46 -04:00
Matthew Cary
299a296c7a update-bazel
Change-Id: Iebc99ee13587f0cd4c43ab85c7295d458d679d1e
2020-09-18 00:44:39 +00:00
Matthew Cary
f2e23afcf1 Adds filtering of hosts to DialContexts.
The provided DialContext wraps existing clients' DialContext in an attempt to
preserve any existing timeout configuration. In some cases, we may replace
infinite timeouts with golang defaults.

- scaleio: tcp connect/keepalive values changed from 0/15 to 30/30
- storageos: no change
2020-09-18 00:07:32 +00:00
Matthew Cary
74dbf274d9 update storageos vendor for FilteredDial change 2020-09-18 00:07:32 +00:00
Amim Knabben
a18e5de51a LockToDefault the ExternalPolicyForExternalIP feature gate 2020-09-16 13:16:33 -04:00
tangwz
a143803066 remove feature gate SupportIPVSProxyMode. 2020-09-10 09:03:00 +08:00
elweb9858
b29379687f Updating winkernel kube-proxy OWNERS file 2020-09-03 14:55:09 -07:00
Kubernetes Prow Robot
b2cba08217
Merge pull request #93979 from dcbw/userspace-proxy-test-waitgroups
proxy/userspace: use waitgroups instead of sketchy atomic ops in testcases
2020-09-02 17:05:40 -07:00
Dan Williams
0cb5e55409 proxy/userspace: clean up and consolidate testcase setup 2020-09-02 16:20:13 -05:00
Dan Williams
1372bd94fe proxy/userspace: use waitgroups instead of sketchy atomic ops in testcases
Instead of relying on atomic ops to increment/decrement at the right time
just use waitgroups to provide hard synchronization points.
2020-09-02 16:20:13 -05:00
Daniel Smith
a86afc12df update scripts 2020-09-02 10:49:40 -07:00
Daniel Smith
75f835aa08 move port definitions to a common location 2020-09-02 10:48:25 -07:00
Kubernetes Prow Robot
163504e9ae
Merge pull request #94107 from robscott/kube-proxy-source-ranges-fix
Updating kube-proxy to trim space from loadBalancerSourceRanges
2020-09-01 18:43:51 -07:00