The issue
When setting up nodes for my k3s cluster, I noticed that some nodes were not able to communicate with each other. After some digging, I found the issue was that nodes were joining the cluster with wrong IPs.
When each node has two IPs like this, (/etc/network/interfaces
)
|
|
they might join the cluster using the DHCP IP, not the static one
|
|
This is problematic, as it sometimes prevents pods running on these nodes from accessing kubernetes’ internal IPs.
In my case, dropping the DHCP IP was not an option, since internet was only reachable on the /24 subnet, and my static IPs live on the /16 subnet.
Solution
It turns out we can keep both IPs, and
- use the /24 one for internet access (default route)
- use the /16 one for in-cluster communication
To do that, all we need to do is edit the k3s service units on each host.
|
|
Adding this argument to the startup command would tell k3s to use a specific IP.
|
|
Example for a worker node:
|
|
Finally, restart the k3s services on each node.
For master nodes,
|
|
For worker nodes,
|
|