Commit Graph

100 Commits

Author SHA1 Message Date
Rob Scott
f07be06a19
Adding support for TopologyAwareHints to kube-proxy 2021-03-08 15:37:47 -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
jornshen
97a5a3d4d5 migrate to use k8s.io/util LocalPort and ListenPortOpener in ipvs.proxier 2021-02-15 16:36:08 +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
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
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
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
jornshen
5af5a2ac7d migrate proxy.UpdateServiceMap to be a method of ServiceMap 2021-01-11 11:07:30 +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
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
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
Patrik Cyvoct
11b97e9ef8
fix tests
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2020-11-07 10:00:55 +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
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
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
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
Amim Knabben
a18e5de51a LockToDefault the ExternalPolicyForExternalIP feature gate 2020-09-16 13:16:33 -04:00
Christopher M. Luciano
65ff4e8227
ipvs: log error if scheduler does not exist and fallback to rr
Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>
2020-07-23 13:58:02 -04:00
Christopher M. Luciano
e2a0eddaf0
ipvs: ensure selected scheduler kernel modules are loaded
Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>
2020-07-16 13:21:54 -04:00
Andrew Sy Kim
de2ecd7e2f proxier/ipvs: check already binded addresses in the IPVS dummy interface
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
Co-authored-by: Laurent Bernaille <laurent.bernaille@gmail.com>
2020-07-02 15:32:21 -04:00
Vinod K L Swamy
4505d5b182
Changes to Proxy common code 2020-06-29 14:29:46 -07:00
Minhan Xia
068963fc06 add testing 2020-03-13 14:59:40 -07:00
Satyadeep Musuvathy
8c6956e5bb Refactor handling of local traffic detection. 2020-02-21 17:57:34 -08:00
Michael Beaumont
3eea0d1405
kube-proxy: Only open ipv4 sockets for ipv4 clusters 2020-01-30 18:54:16 +01:00
SataQiu
2497a1209b bump k8s.io/utils version 2019-12-21 14:54:44 +08:00
Roc Chan
c9cf3f5b72 Service Topology implementation
* Implement Service Topology for ipvs and iptables proxier
* Add test files
* API validation
2019-11-15 13:36:43 +08:00
Rob Scott
a7e589a8c6
Promoting EndpointSlices to beta 2019-11-13 14:20:19 -08:00
Rob Scott
0fa9981e01
Splitting IP address type into IPv4 and IPv6 for EndpointSlices 2019-11-12 09:03:53 -08:00
Dan Winship
0f10102c16 Better distinguish the two kinds of proxy health check servers
Kube-proxy runs two different health servers; one for monitoring the
health of kube-proxy itself, and one for monitoring the health of
specific services. Rename them to "ProxierHealthServer" and
"ServiceHealthServer" to make this clearer, and do a bit of API
cleanup too.
2019-10-04 10:37:58 -04:00
Rob Scott
af56f25797
Only detecting stale connections for UDP ports in kube-proxy.
The detectStaleConnections function in kube-proxy is very expensive in
terms of CPU utilization. The results of this function are only actually
used for UDP ports. This adds a protocol attribute to ServicePortName to
make it simple to only run this function for UDP connections. For
clusters with primarily TCP connections this can improve kube-proxy
performance by 2x.
2019-09-25 17:48:54 -07:00
Kubernetes Prow Robot
61ecdba9ca
Merge pull request #82289 from robscott/endpointslice-fixes
Fixing bugs related to Endpoint Slices
2019-09-05 09:03:10 -07:00
Rob Scott
8f9483d827
Fixing bugs related to Endpoint Slices
This should fix a bug that could break masters when the EndpointSlice
feature gate was enabled. This was all tied to how the apiserver creates
and manages it's own services and endpoints (or in this case endpoint
slices). Consumers of endpoint slices also need to know about the
corresponding service. Previously we were trying to set an owner
reference here for this purpose, but that came with potential downsides
and increased complexity. This commit changes behavior of the apiserver
endpointslice integration to set the service name label instead of owner
references, and simplifies consumer logic to reference that (both are
set by the EndpointSlice controller).

Additionally, this should fix a bug with the EndpointSlice GenerateName
value that had previously been set with a "." as a suffix.
2019-09-04 09:09:32 -07:00
Kubernetes Prow Robot
542f3c65a0
Merge pull request #78547 from MikeSpreitzer/fix-76699
Make iptables and ipvs modes of kube-proxy MASQUERADE --random-fully if possible
2019-09-03 14:34:58 -07:00
Mike Spreitzer
d86d1defa1 Made IPVS and iptables modes of kube-proxy fully randomize masquerading if possible
Work around Linux kernel bug that sometimes causes multiple flows to
get mapped to the same IP:PORT and consequently some suffer packet
drops.

Also made the same update in kubelet.

Also added cross-pointers between the two bodies of code, in comments.

Some day we should eliminate the duplicate code.  But today is not
that day.
2019-09-01 22:07:30 -04:00
Khaled Henidak(Kal)
465255425e create meta-proxy for proxy-mode=ipvs (dualstack)
co-authored-by: Lars Ekman <lars.g.ekman@est.tech>
2019-08-29 23:37:37 +00:00
Rob Scott
9665c590c7
Adding EndpointSlice support for kube-proxy ipvs and iptables proxiers 2019-08-29 01:06:52 -07:00
Subrata Paul
138b8b8aaa Fix in kube-proxy for sctp ipset entries
Kube-proxy will add ipset entries for all node ips for an SCTP nodeport service. This will solve the problem 'SCTP nodeport service is not working for all IPs present in the node when ipvs is enabled. It is working only for node's InternalIP.'
2019-08-18 00:40:27 +05:30
Andrew Sy Kim
459bfb1ab7 proxy/ipvs: test cleanLegacyService with real servers
Signed-off-by: Andrew Sy Kim <kiman@vmware.com>
2019-08-13 11:55:16 -04:00
Kubernetes Prow Robot
6d921c0eb5
Merge pull request #80779 from andrewsykim/ipvs-test-tables
proxy/ipvs: refactor IPVS unit tests TestClusterIP and TestNodePort to use test tables
2019-08-13 07:55:42 -07:00
Emrecan BATI
90ce2d50d3 Add GetKernelVersion to ipvs.KernelHandler interface
ipvs `getProxyMode` test fails on mac as `utilipvs.GetRequiredIPVSMods`
try to reach `/proc/sys/kernel/osrelease` to find version of the running
linux kernel. Linux kernel version is used to determine the list of required
kernel modules for ipvs.

Logic to determine kernel version is moved to GetKernelVersion
method in LinuxKernelHandler which implements ipvs.KernelHandler.
Mock KernelHandler is used in the test cases.

Read and parse file is converted to go function instead of execing cut.
2019-07-31 22:10:44 +03:00
Andrew Sy Kim
089e0cd9ef proxy/ipvs: refactor TestNodePort to use test tables
Signed-off-by: Andrew Sy Kim <kiman@vmware.com>
2019-07-30 22:04:52 -04:00
Andrew Sy Kim
9af797c51e proxy/ipvs: refactor TestClusterIP to use test tables
Signed-off-by: Andrew Sy Kim <kiman@vmware.com>
2019-07-30 21:30:52 -04:00
yanghaichao12
66aa7c973d delete unused code in proxier_test 2019-05-27 10:39:43 -04:00
Jacob Tanenbaum
9d4693a70f changing UpdateEndpointsMap to Update
changing UpdateEndpointsMap to be a function of the EndpointsMap object
2019-05-07 14:41:15 -04:00
Ted Yu
9d30833e53 Follow on for #76779 2019-04-25 02:46:38 -07:00
Ted Yu
0062a7d8de Store parsed CIDRs at initialization of Proxier 2019-04-18 09:36:05 -07:00
Igor German
107faf5ab0 proxy: Take into account exclude CIDRs while deleting legacy real servers 2019-04-11 17:05:49 +03:00
Laurent Bernaille
09f821ddb5 [kube-proxy/ipvs] Add flag to enable strict ARP 2019-03-12 15:56:22 +01:00