create VM running k3s

This commit is contained in:
Pim Kunis 2024-02-11 14:18:11 +01:00
parent 5865e8a95a
commit 03e816ff21
3 changed files with 33 additions and 7 deletions

View file

@ -10,13 +10,17 @@ in {
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.k3s ];
networking.firewall.allowedTCPPorts = [ 6443 ];
environment.systemPackages = with pkgs; [ k3s ];
networking = {
nftables.enable = lib.mkForce false;
firewall.enable = lib.mkForce false;
};
services.k3s = {
enable = true;
role = "server";
extraFlags = "--tls-san ${config.networking.fqdn} --data-dir ${config.lab.dataDisk.mountPoint}/k3s";
extraFlags = "--tls-san ${config.networking.fqdn} --snapshotter native";
};
system.activationScripts.k3s-bootstrap.text =
@ -26,7 +30,7 @@ in {
}).config.kubernetes.result;
in
''
ln -sf ${k3sBootstrapFile} ${config.lab.dataDisk.mountPoint}/k3s/server/manifests/k3s-bootstrap.json
ln -sf ${k3sBootstrapFile} /var/lib/rancher/k3s/server/manifests/k3s-bootstrap.json
'';
};
}