Watch
0
0
Fork
You've already forked hyperhive
0

k8s: networkmanager leaves the pod network's interfaces unmanaged

This commit is contained in:
atlas 2026-11-28 05:36:49 +01:00 • committed by maia
commit 0998c82555
2 changed files with 52 additions and 1 deletions

View file

@ -515,6 +515,19 @@ in
];
})
# NetworkManager manages every interface it finds unless told not to, and
# rewrites the routes and addresses of the ones the cluster creates: `cni0`
# (the bridge CNI), `flannel-wg` and the other `flannel*` devices, and the
# host end of each pod's veth pair (`veth*`). The same applies on a joining
# node, which runs the same CNI. A host without NetworkManager is left alone.
(lib.mkIf ((cfg.enable || cfg.join != null) && config.networking.networkmanager.enable) {
networking.networkmanager.unmanaged = [
"interface-name:cni0"
"interface-name:flannel*"
"interface-name:veth*"
];
})
# An agent of another host's cluster. The server's manifests and units are
# not here: the pods it runs come from the main node's API.
(lib.mkIf (cfg.join != null && !cfg.enable) {

View file

@ -58,6 +58,16 @@ let
}
);
# The node with NetworkManager on, a host that has no node with it on, and
# (below, `joined`) an agent with it on. `allLocal` is the node with it off.
networkManagerOn = {
networking.networkmanager.enable = true;
};
nodeWithNm = hiveWith [ networkManagerOn ] (
lib.recursiveUpdate { deploy.hive-controller.enable = true; } nodeSettings
);
noClusterWithNm = hiveWith [ networkManagerOn ] { deploy.hive-controller.enable = false; };
# Two hives on a store host with the node: the policy of each differs by the
# join token. Shares nothing of `onCluster`'s controller, which lists the
# hives.
@ -81,7 +91,7 @@ let
# A host that joins that cluster: an agent with the store identity its join
# token is read under. The only fixture without `deploy.k8s.enable`, which
# is what it claims about.
joined = hiveWith [ semiSpreadWg ] {
joined = hiveWith [ semiSpreadWg networkManagerOn ] {
deploy.k8s.join.server = "192.168.1.10";
deploy.k8s.address = "192.168.1.11";
deploy.hive-controller.tls = {
@ -461,6 +471,28 @@ let
&& refuses "overlap the hive bridge"
&& refuses "overlap each other";
}
{
# NetworkManager rewrites the routes of the interfaces the CNI makes, so
# it is told to leave `cni0`, flannel's devices and the pods' veth ends
# alone, on the node and on an agent. The literals are spelled here, not
# read from the module. Each absence arm has its presence control: the
# node and the agent have the list, so the lookup finds it where it is.
name = "NetworkManager leaves the pod network's interfaces unmanaged on a node and on an agent, and is untouched where it is off or where there is no cluster";
ok =
let
expected = [
"interface-name:cni0"
"interface-name:flannel*"
"interface-name:veth*"
];
in
nodeWithNm.networking.networkmanager.unmanaged == expected
&& joined.networking.networkmanager.unmanaged == expected
&& !allLocal.networking.networkmanager.enable
&& allLocal.networking.networkmanager.unmanaged == [ ]
&& noClusterWithNm.networking.networkmanager.enable
&& noClusterWithNm.networking.networkmanager.unmanaged == [ ];
}
{
# An agent takes the backend from its server, and `--flannel-backend` is
# a server flag that an agent refuses, so the agent's flags carry none.