init k3s config
not finished but a pointer in the right direction
This commit is contained in:
parent
6c7781e325
commit
8a2acb343b
3 changed files with 76 additions and 2 deletions
45
modules/nixos/common/k3s.nix
Normal file
45
modules/nixos/common/k3s.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
types
|
||||
mkIf
|
||||
mkOption
|
||||
mkEnableOption
|
||||
;
|
||||
cfg = config.kub;
|
||||
in
|
||||
{
|
||||
options.kub = {
|
||||
enable = mkEnableOption "enable k3s";
|
||||
role = mkOption {
|
||||
type = types.enum [
|
||||
"server"
|
||||
"agent"
|
||||
];
|
||||
default = "agent";
|
||||
};
|
||||
leaderAddress = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
tokenFile = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
description = "File path containing k3s token to use when connecting to the server.";
|
||||
default = config.sops.secrets.k3s-token.path or null;
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
sops.secrets.k3s-token = { };
|
||||
services = {
|
||||
k3s = {
|
||||
enable = true;
|
||||
clusterInit = mkIf (cfg.role == "server") true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue