mirror of
https://github.com/michaelthomson0797/nixos-server.git
synced 2026-03-21 19:17:23 +00:00
54 lines
1015 B
Nix
54 lines
1015 B
Nix
{
|
|
config,
|
|
lib,
|
|
meta,
|
|
...
|
|
}:
|
|
with lib; let
|
|
cfg = config.k3s;
|
|
in {
|
|
options.k3s = {
|
|
init = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = "Initialize cluster when set to true";
|
|
};
|
|
role = mkOption {
|
|
type = types.str;
|
|
default = "server";
|
|
};
|
|
};
|
|
|
|
config = {
|
|
services = {
|
|
k3s = {
|
|
enable = true;
|
|
role =
|
|
if cfg.init
|
|
then "server"
|
|
else cfg.role;
|
|
clusterInit = cfg.init;
|
|
serverAddr =
|
|
if cfg.init
|
|
then ""
|
|
else meta.serverAddr;
|
|
token =
|
|
if cfg.init
|
|
then ""
|
|
else meta.k3sToken;
|
|
disable =
|
|
if cfg.init
|
|
then ["traefik" "servicelb" "local-storage"]
|
|
else [];
|
|
extraFlags =
|
|
if cfg.init
|
|
then [
|
|
"--kubelet-arg=allowed-unsafe-sysctls=net.ipv4.*"
|
|
"--write-kubeconfig-mode \"0644\""
|
|
]
|
|
else [];
|
|
};
|
|
};
|
|
};
|
|
}
|