create VM running k3s
This commit is contained in:
parent
5865e8a95a
commit
03e816ff21
3 changed files with 33 additions and 7 deletions
|
@ -56,7 +56,6 @@
|
|||
};
|
||||
};
|
||||
|
||||
# TODO: make leases persistent!
|
||||
hermes = {
|
||||
type = "virtual";
|
||||
hypervisorName = "lewis";
|
||||
|
@ -67,6 +66,7 @@
|
|||
|
||||
vm = {
|
||||
# TODO: would be cool to create a check that a mac address is only ever assigned to one VM.
|
||||
# TODO: idea: what if we generated these IDs by hashing the host name and reducing that to the amount of hosts possible?
|
||||
id = 7;
|
||||
staticNetworking = true;
|
||||
staticIPv4 = config.lab.networking.dmz.ipv4.services;
|
||||
|
@ -125,4 +125,26 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
k3s = {
|
||||
type = "virtual";
|
||||
hypervisorName = "atlas";
|
||||
|
||||
nixosModule = {
|
||||
microvm.balloonMem = 7680;
|
||||
|
||||
lab = {
|
||||
k3s.enable = true;
|
||||
|
||||
vm = {
|
||||
id = 4;
|
||||
|
||||
shares = [{
|
||||
name = "k3s";
|
||||
mountPoint = "/var/lib/rancher/k3s";
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs, config, lib, modulesPath, microvm, disko, agenix, machines, dns, ... }: {
|
||||
{ pkgs, config, lib, modulesPath, microvm, disko, agenix, machines, dns, kubenix, ... }: {
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
microvm.nixosModules.host
|
||||
|
@ -62,7 +62,7 @@
|
|||
(name: vm:
|
||||
{
|
||||
# TODO Simplify?
|
||||
specialArgs = { inherit agenix disko pkgs lib microvm dns; machine = vm; hypervisorConfig = config; };
|
||||
specialArgs = { inherit agenix disko pkgs lib microvm dns kubenix; machine = vm; hypervisorConfig = config; };
|
||||
config.imports = [
|
||||
./.
|
||||
{ networking.hostName = name; }
|
||||
|
|
Loading…
Reference in a new issue