refactor: generate kubeadm host configs from flake
All checks were successful
Terraform Plan / Terraform Plan (push) Successful in 17s
All checks were successful
Terraform Plan / Terraform Plan (push) Successful in 17s
This commit is contained in:
@@ -8,19 +8,31 @@
|
||||
outputs = { nixpkgs, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
mkHost = hostModules:
|
||||
lib = nixpkgs.lib;
|
||||
|
||||
mkNode = { name, role }:
|
||||
let
|
||||
roleModule = if role == "control-plane" then ./modules/k8s-control-plane.nix else ./modules/k8s-worker.nix;
|
||||
hardwarePath = ./hosts/hardware + "/${name}.nix";
|
||||
in
|
||||
nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = hostModules;
|
||||
modules = [
|
||||
./modules/k8s-cluster-settings.nix
|
||||
./modules/k8s-common.nix
|
||||
roleModule
|
||||
({ lib, ... }: {
|
||||
imports = lib.optional (builtins.pathExists hardwarePath) hardwarePath;
|
||||
networking.hostName = name;
|
||||
system.stateVersion = "25.05";
|
||||
})
|
||||
];
|
||||
};
|
||||
in {
|
||||
nixosConfigurations = {
|
||||
cp-1 = mkHost [ ./hosts/cp-1.nix ];
|
||||
cp-2 = mkHost [ ./hosts/cp-2.nix ];
|
||||
cp-3 = mkHost [ ./hosts/cp-3.nix ];
|
||||
wk-1 = mkHost [ ./hosts/wk-1.nix ];
|
||||
wk-2 = mkHost [ ./hosts/wk-2.nix ];
|
||||
wk-3 = mkHost [ ./hosts/wk-3.nix ];
|
||||
};
|
||||
nixosConfigurations = lib.genAttrs [ "cp-1" "cp-2" "cp-3" "wk-1" "wk-2" "wk-3" ] (name:
|
||||
mkNode {
|
||||
inherit name;
|
||||
role = if lib.hasPrefix "cp-" name then "control-plane" else "worker";
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user