Skip to content

net/interfaces: Don't connect over Kubernetes network interfaces - #8682

Open
oscrx wants to merge 1 commit into
tailscale:mainfrom
oscrx:main
Open

oscrx wants to merge 1 commit into
tailscale:mainfrom
oscrx:main

Conversation

@oscrx

@oscrx oscrx commented Jul 22, 2023

Copy link
Copy Markdown

I use Tailscale for the control plane node communication of my Kubernetes cluster.

A routing loop had been happening every so often. Resulting in major cpu spikes all over the cluster.

After some research I found out magicsock was preferring internal routes provided by Cilium.
I was following this issue in the hope it would solve my problem: #1552

That would be the ultimate solution, a flag where specific interfaces could be excluded.

Today I noticed this PR however.
https://github.com/tailscale/tailscale/pull/1210/files

And even with my little go experience I knew I could extend this exclusion of unwanted interfaces a little bit more.
I also found other users having the same issue with Calico: #7594

This would probably solve that issue as well.

I'm currently running a custom build of it and it runs silky smooth.

I hope this will be sufficient and am open for any feedback!

@oscrx oscrx changed the title Ignore Kubernetes network interfaces net/interfaces: Don't send over Kubernetes network interfaces Jul 22, 2023
@bradfitz

Copy link
Copy Markdown
Member

While this fixes you, it likely breaks somebody else where this was their only or best path.

The real problem is the amplification. Why's that happening? Let's fix that instead.

@oscrx

oscrx commented Jul 22, 2023

Copy link
Copy Markdown
Author

The nodes in my cluster are spread out geografically and are not in the same networks. With Tailscale they can communicate with each other (with stable ip addresses). I use Cilium for internal cluster communication.

When tailscale decides the 'local' kubernetes interface is preffered it is actually using it's own tunnel causing the cpu to go to 100% utilisation.

Functionality to exclude certain interfaces would be the better option. But the implementation of such functionality is not trivial (for me)

@bradfitz

Copy link
Copy Markdown
Member

using its own tunnel causing the cpu to go to 100% utilisation.

But why?

What's the loop?

@oscrx

oscrx commented Aug 18, 2023

Copy link
Copy Markdown
Author

Sorry, I missed your reply.

I don't know what causes the loop.
I'm not even 100% sure if it is a loop.

I will try to describe the pattern that I see:

  1. Tailscale sets up the network between the nodes.
  2. Cilium sets up some tunnel interfaces for containers to communicate over the cluster.
  3. Tailscale keeps trying to find the best path.
  4. At some point it thinks that the Cilium tunnel interface is the most optimal connection.
  5. The CPU usage explodes.

I know that the code doesn't feel optimal, but the 'skip Zerotier' code that is above it is basically the same.
Until the real cause is found this seemed like the best solution.

This is what the cilium_host interface looks like:

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 1e:81:e9:0f:f5:07 brd ff:ff:ff:ff:ff:ff
    altname enp0s18
    inet 192.168.123.222/23 metric 100 brd 192.168.123.255 scope global dynamic ens18
       valid_lft 79705sec preferred_lft 79705sec
    inet6 2a02:a470:edcd:0:1c81:e9ff:fe0f:f507/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 86269sec preferred_lft 14269sec
    inet6 fe80::1c81:e9ff:fe0f:f507/64 scope link 
       valid_lft forever preferred_lft forever
3: tailscale0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1280 qdisc fq_codel state UNKNOWN group default qlen 500
    link/none 
    inet 100.64.0.7/32 scope global tailscale0
       valid_lft forever preferred_lft forever
    inet6 fdd3:a7d6:38c5::7/128 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::fa47:cd49:67f:dad5/64 scope link stable-privacy 
       valid_lft forever preferred_lft forever
4: cilium_net@cilium_host: <BROADCAST,MULTICAST,NOARP,UP,LOWER_UP> mtu 1280 qdisc noqueue state UP group default qlen 1000
    link/ether 56:2d:30:d9:40:34 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::542d:30ff:fed9:4034/64 scope link 
       valid_lft forever preferred_lft forever
5: cilium_host@cilium_net: <BROADCAST,MULTICAST,NOARP,UP,LOWER_UP> mtu 1280 qdisc noqueue state UP group default qlen 1000
    link/ether 9a:3f:b7:88:1b:b6 brd ff:ff:ff:ff:ff:ff
    inet 10.0.1.193/32 scope global cilium_host
       valid_lft forever preferred_lft forever
    inet6 fdd3:a7d6:38c5::7/128 scope global 
       valid_lft forever preferred_lft forever
6: cilium_vxlan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1280 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether b2:36:7a:fc:fb:83 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::b036:7aff:fefc:fb83/64 scope link 
       valid_lft forever preferred_lft forever
1554: lxc307eef7f217a@if1553: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1280 qdisc noqueue state UP group default qlen 1000
    link/ether f2:32:7d:71:15:a5 brd ff:ff:ff:ff:ff:ff link-netns 1a8faef5-4ca0-48d3-831a-c8aecc29a0c0
    inet6 fe80::f032:7dff:fe71:15a5/64 scope link 
       valid_lft forever preferred_lft forever
...

Unfortunately I don't seem to have the logs of the issue anymore, but I posted a screenshot of the problem a few months back: #1552 (comment) (10.240.0.0/16 was my cilium range at the time)
Notice the huge traffic volume just after restart of the Tailscale daemons.

@oscrx oscrx changed the title net/interfaces: Don't send over Kubernetes network interfaces net/interfaces: Don't connect over Kubernetes network interfaces Aug 18, 2023
// preferring/trying to use each other for transport. See:
// https://github.com/tailscale/tailscale/issues/7594
// https://github.com/tailscale/tailscale/issues/1552
if strings.HasPrefix(name, "cilium") || strings.HasPrefix(name, "cali") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do note that if you truly want to exclude all the network interfaces created by a Kubernetes CNI, the list is going to be huge.

For instance, for flannel it's flannel.X.

I feel like there should be a better way than excluding predefined interface names.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a config option to prevent this behavior would be better.
Like the one discussed here: #1552

@justyns

justyns commented Sep 2, 2024

Copy link
Copy Markdown

FWIW this PR or something similar is still desired. I am running into something similar where tailscale occasionally tries to route over cilium (which is already using the tailscale interface) and causes high cpu usage and connectivity blips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants