-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Describe the Issue
In the current configuration, all k3s nodes appear to be initialized with the --cluster-init flag, despite clusterInit being explicitly set to true only for the primary node (homelab-0). This results in unintended behavior where each server in the cluster runs as an initial server node.
homelab/nixos/configuration.nix
Lines 55 to 69 in 1491d75
| services.k3s = { | |
| enable = true; | |
| role = "server"; | |
| tokenFile = /var/lib/rancher/k3s/server/token; | |
| extraFlags = toString ([ | |
| "--write-kubeconfig-mode \"0644\"" | |
| "--cluster-init" | |
| "--disable servicelb" | |
| "--disable traefik" | |
| "--disable local-storage" | |
| ] ++ (if meta.hostname == "homelab-0" then [] else [ | |
| "--server https://homelab-0:6443" | |
| ])); | |
| clusterInit = (meta.hostname == "homelab-0"); | |
| }; |
services.k3s = {
enable = true;
role = "server";
tokenFile = /var/lib/rancher/k3s/server/token;
extraFlags = toString ([
"--write-kubeconfig-mode \"0644\""
"--cluster-init"
"--disable servicelb"
"--disable traefik"
"--disable local-storage"
] ++ (if meta.hostname == "homelab-0" then [] else [
"--server https://homelab-0:6443"
]));
clusterInit = (meta.hostname == "homelab-0");
}; The expectation is that clusterInit would apply only to homelab-0. However, setting --cluster-init in extraFlags causes all nodes to receive this flag, effectively overriding the clusterInit condition.
Relevant Code in nixpkgs
The NixOS k3s service configuration processes clusterInit separately from extraFlags, meaning additional flags in extraFlags are simply appended rather than overriding the conditions set by clusterInit:
Expected Behavior
Only the primary node, homelab-0, should initialize the cluster with --cluster-init, while all other nodes should connect to it using --server https://homelab-0:6443.