Score:1

Is there a way to add multicast to loopback interface on a kubernetes pod?

cn flag

Using an in-prem kubernetes installation on baremetal (Ubuntu) servers, installed with kubeadm.

Kubernetes version is 1.25.3

Need to have multicast on a pod's loopback for the automated tests running, and I didn't find a way to get it. For a single-pod scenario it's probably possible by using the host network in yaml:

hostNetwork: true

But it's not an option in our case since we have multiple pods running simultaneously for this task, and we'll loose the pods isolation then.

Running ifconfig lo multicast within a pod under a root returns Operation not permitted

I wonder is there any feasible way to get multicast on a pod's loopback? Doesn't look to me that it's technically impossible, but I can't see how I could get it...

Thanks!

Score:0
cn flag

I found a way to do it, but even though eventually it turned out to be not that difficult, still it requires recompiling some binaries so it's rather tough so far (but like I said, doable)

Hopefully the CNI plugins (part of k8s installation, see below) will be updated, then I will update my answer too. Meanwhile, here is a solution that so far worked perfectly for me:

This worked for vanilla kubeadm-based kubernetes installation, and probably would work for any kubernetes distribution/installation that allows to replace CNI plugins binaries. E.g. for a kubeadm-based way, if containerd is used, there is the following step:

...
Use the following commands to install Containerd on your system:
Follow the instructions for getting started with containerd...

In turn, the "getting started page" contains instructions to install the CNI plugins:

...
Step 3: Installing CNI plugins 
... and extract it under /opt/cni/bin 
...
... ./loopback
...

That's where the loopback plugin binary can be replaced (it can be done after k8s installation too as long as it's found on all nodes). The replacement one can be prepared using either the PR or the source fork repo (see multicast-on-loopback branch in the latter).

The actual change is rather simple, all that needs to be done is figuring out how to recompile the plugins after applying it (this also looks quite straightforward) and then replace the original loopback binary (found as described above) with the built one.

Notice that the binary needs to be replaced on all nodes, even though originally it's installed onto master only.

After the binary is replaced, just in case I restarted all nodes in the cluster, and voila - a perfectly workable multicast on loopback is here in each of the pods. Of course, the original loopback binary should be backed up first.

I checked that MC is isolated within a pod, to do that I've run iperf on multiple pods. From what I see it's all good, and it's actually isolated properly, i.e. loopback is still a loopback for a pod only.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.