2023-12-16 14:45:17 +00:00
|
|
|
{ pkgs, lib, config, kubenix, ... }:
|
2023-12-15 13:55:48 +00:00
|
|
|
let cfg = config.custom.k3s;
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
custom = {
|
|
|
|
k3s.enable = lib.mkOption {
|
|
|
|
default = false;
|
|
|
|
type = lib.types.bool;
|
|
|
|
description = ''
|
|
|
|
Whether to start k3s with custom configuration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ pkgs.k3s ];
|
|
|
|
services.k3s.enable = true;
|
|
|
|
services.k3s.role = "server";
|
2023-12-15 14:20:28 +00:00
|
|
|
services.k3s.extraFlags = "--tls-san ${config.networking.fqdn} --data-dir ${config.custom.dataDisk.mountPoint}/k3s";
|
2023-12-15 13:55:48 +00:00
|
|
|
|
|
|
|
system.activationScripts.k3s-bootstrap.text =
|
|
|
|
let
|
2023-12-16 14:45:17 +00:00
|
|
|
k3sBootstrapFile = (kubenix.evalModules.x86_64-linux {
|
|
|
|
module = import ./bootstrap.nix;
|
|
|
|
}).config.kubernetes.result;
|
2023-12-15 13:55:48 +00:00
|
|
|
in
|
|
|
|
''
|
2023-12-16 14:45:17 +00:00
|
|
|
ln -sf ${k3sBootstrapFile} ${config.custom.dataDisk.mountPoint}/k3s/server/manifests/k3s-bootstrap.json
|
2023-12-15 13:55:48 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|