mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-13 12:13:46 +01:00
fix(microvm): run k3s guests from their nixosConfigurations entry (#483)
Assisted-by: DeepSeek Harness 0.2.1-rc.2 (claude-opus-5-5)
This commit is contained in:
1 parent
41f6db32ed
commit
de6a66ccd4
6 files changed
+64
-85
No files matched your search
@@ -1,10 +1,5 @@
|
|||||||
{
|
{
|
||||||
microvm,
|
microvm,
|
||||||
myvars,
|
|
||||||
mylib,
|
|
||||||
agenix,
|
|
||||||
mysecrets,
|
|
||||||
myNurPkgs,
|
|
||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
@@ -12,36 +7,18 @@
|
|||||||
# Run the k3s-test VMs as MicroVMs instead of KubeVirt domains.
|
# Run the k3s-test VMs as MicroVMs instead of KubeVirt domains.
|
||||||
imports = [ microvm.nixosModules.host ];
|
imports = [ microvm.nixosModules.host ];
|
||||||
|
|
||||||
|
# Each guest runs its `nixosConfigurations` entry, the system that `just test`
|
||||||
|
# and `just microvm-deploy` see, instead of a second evaluation on the host.
|
||||||
microvm.vms.k3s-test-1-master-1 = {
|
microvm.vms.k3s-test-1-master-1 = {
|
||||||
autostart = true;
|
autostart = true;
|
||||||
restartIfChanged = true;
|
restartIfChanged = true;
|
||||||
specialArgs = {
|
evaluatedConfig = inputs.self.nixosConfigurations.k3s-test-1-master-1;
|
||||||
inherit
|
|
||||||
inputs
|
|
||||||
myvars
|
|
||||||
mylib
|
|
||||||
agenix
|
|
||||||
mysecrets
|
|
||||||
myNurPkgs
|
|
||||||
;
|
|
||||||
};
|
|
||||||
config.imports = [ ../k8s/k3s-test-1-master-1 ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
microvm.vms.k3s-test-1-worker-1 = {
|
microvm.vms.k3s-test-1-worker-1 = {
|
||||||
autostart = true;
|
autostart = true;
|
||||||
restartIfChanged = true;
|
restartIfChanged = true;
|
||||||
specialArgs = {
|
evaluatedConfig = inputs.self.nixosConfigurations.k3s-test-1-worker-1;
|
||||||
inherit
|
|
||||||
inputs
|
|
||||||
myvars
|
|
||||||
mylib
|
|
||||||
agenix
|
|
||||||
mysecrets
|
|
||||||
myNurPkgs
|
|
||||||
;
|
|
||||||
};
|
|
||||||
config.imports = [ ../k8s/k3s-test-1-worker-1 ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Attach the guest's tap to the VM bridge, the same way the physical NIC is
|
# Attach the guest's tap to the VM bridge, the same way the physical NIC is
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
{
|
{
|
||||||
microvm,
|
microvm,
|
||||||
myvars,
|
|
||||||
mylib,
|
|
||||||
agenix,
|
|
||||||
mysecrets,
|
|
||||||
myNurPkgs,
|
|
||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
@@ -12,36 +7,18 @@
|
|||||||
# Run the k3s-test VMs as MicroVMs instead of KubeVirt domains.
|
# Run the k3s-test VMs as MicroVMs instead of KubeVirt domains.
|
||||||
imports = [ microvm.nixosModules.host ];
|
imports = [ microvm.nixosModules.host ];
|
||||||
|
|
||||||
|
# Each guest runs its `nixosConfigurations` entry, the system that `just test`
|
||||||
|
# and `just microvm-deploy` see, instead of a second evaluation on the host.
|
||||||
microvm.vms.k3s-test-1-master-3 = {
|
microvm.vms.k3s-test-1-master-3 = {
|
||||||
autostart = true;
|
autostart = true;
|
||||||
restartIfChanged = true;
|
restartIfChanged = true;
|
||||||
specialArgs = {
|
evaluatedConfig = inputs.self.nixosConfigurations.k3s-test-1-master-3;
|
||||||
inherit
|
|
||||||
inputs
|
|
||||||
myvars
|
|
||||||
mylib
|
|
||||||
agenix
|
|
||||||
mysecrets
|
|
||||||
myNurPkgs
|
|
||||||
;
|
|
||||||
};
|
|
||||||
config.imports = [ ../k8s/k3s-test-1-master-3 ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
microvm.vms.k3s-test-1-worker-3 = {
|
microvm.vms.k3s-test-1-worker-3 = {
|
||||||
autostart = true;
|
autostart = true;
|
||||||
restartIfChanged = true;
|
restartIfChanged = true;
|
||||||
specialArgs = {
|
evaluatedConfig = inputs.self.nixosConfigurations.k3s-test-1-worker-3;
|
||||||
inherit
|
|
||||||
inputs
|
|
||||||
myvars
|
|
||||||
mylib
|
|
||||||
agenix
|
|
||||||
mysecrets
|
|
||||||
myNurPkgs
|
|
||||||
;
|
|
||||||
};
|
|
||||||
config.imports = [ ../k8s/k3s-test-1-worker-3 ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Attach the guest's tap to the VM bridge, the same way the physical NIC is
|
# Attach the guest's tap to the VM bridge, the same way the physical NIC is
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
{
|
{
|
||||||
microvm,
|
microvm,
|
||||||
myvars,
|
|
||||||
mylib,
|
|
||||||
agenix,
|
|
||||||
mysecrets,
|
|
||||||
myNurPkgs,
|
|
||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
@@ -12,20 +7,12 @@
|
|||||||
# Run the k3s-test VMs as MicroVMs instead of KubeVirt domains.
|
# Run the k3s-test VMs as MicroVMs instead of KubeVirt domains.
|
||||||
imports = [ microvm.nixosModules.host ];
|
imports = [ microvm.nixosModules.host ];
|
||||||
|
|
||||||
|
# Each guest runs its `nixosConfigurations` entry, the system that `just test`
|
||||||
|
# and `just microvm-deploy` see, instead of a second evaluation on the host.
|
||||||
microvm.vms.k3s-test-1-master-2 = {
|
microvm.vms.k3s-test-1-master-2 = {
|
||||||
autostart = true;
|
autostart = true;
|
||||||
restartIfChanged = true;
|
restartIfChanged = true;
|
||||||
specialArgs = {
|
evaluatedConfig = inputs.self.nixosConfigurations.k3s-test-1-master-2;
|
||||||
inherit
|
|
||||||
inputs
|
|
||||||
myvars
|
|
||||||
mylib
|
|
||||||
agenix
|
|
||||||
mysecrets
|
|
||||||
myNurPkgs
|
|
||||||
;
|
|
||||||
};
|
|
||||||
config.imports = [ ../k8s/k3s-test-1-master-2 ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Moved here from shushou after the SSD swap: the 5625U there is weaker and has
|
# Moved here from shushou after the SSD swap: the 5625U there is weaker and has
|
||||||
@@ -33,17 +20,7 @@
|
|||||||
microvm.vms.k3s-test-1-worker-2 = {
|
microvm.vms.k3s-test-1-worker-2 = {
|
||||||
autostart = true;
|
autostart = true;
|
||||||
restartIfChanged = true;
|
restartIfChanged = true;
|
||||||
specialArgs = {
|
evaluatedConfig = inputs.self.nixosConfigurations.k3s-test-1-worker-2;
|
||||||
inherit
|
|
||||||
inputs
|
|
||||||
myvars
|
|
||||||
mylib
|
|
||||||
agenix
|
|
||||||
mysecrets
|
|
||||||
myNurPkgs
|
|
||||||
;
|
|
||||||
};
|
|
||||||
config.imports = [ ../k8s/k3s-test-1-worker-2 ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Attach the guest's tap to the VM bridge, the same way the physical NIC is
|
# Attach the guest's tap to the VM bridge, the same way the physical NIC is
|
||||||
|
|||||||
+4
-4
@@ -47,10 +47,10 @@ Some tests iterate over every configuration, so a new host is covered automatica
|
|||||||
them. Others name specific hosts — or a name prefix, like `k3s-api-endpoint`, which covers every
|
them. Others name specific hosts — or a name prefix, like `k3s-api-endpoint`, which covers every
|
||||||
`k3s-test-1-*` configuration — and only cover a new host if you add it.
|
`k3s-test-1-*` configuration — and only cover a new host if you add it.
|
||||||
|
|
||||||
| Kind | Tests |
|
| Kind | Tests |
|
||||||
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Every configuration | `hostname`, `kernel`, `nix-system-features`, `security-apparmor`, `security-container-groups`, `security-exporters`, `security-firewall`, `security-k3s-kubeconfig`, `security-k3s-pod-firewall`, `security-kernel`, `security-ssh-x11` |
|
| Every configuration | `hostname`, `kernel`, `nix-system-features`, `security-apparmor`, `security-container-groups`, `security-exporters`, `security-firewall`, `security-k3s-kubeconfig`, `security-k3s-pod-firewall`, `security-kernel`, `security-ssh-x11` |
|
||||||
| Named hosts only | `btrbk`, `cpu-power`, `home-manager`, `home-manager-xdg`, `computer-use-headless`, `k3s-api-endpoint`, `k3s-node-home-manager`, `idols-ai-gpu`, `idols-ai-net`, `idols-ai-voice-input`, `idols-aquamarine`, `security-postgres-auth`, `youko-metrics`, `ups-metrics`, `shoukei-logind`, `mihomo-dns`, `vm-host-power`, `colmena-parity` |
|
| Named hosts only | `btrbk`, `cpu-power`, `home-manager`, `home-manager-xdg`, `computer-use-headless`, `k3s-api-endpoint`, `k3s-node-home-manager`, `idols-ai-gpu`, `idols-ai-net`, `idols-ai-voice-input`, `idols-aquamarine`, `security-postgres-auth`, `youko-metrics`, `ups-metrics`, `shoukei-logind`, `mihomo-dns`, `colmena-parity`, `microvm-guest-parity` |
|
||||||
|
|
||||||
`hostname` expects each configuration's `networking.hostName` to equal its name. Niri desktop
|
`hostname` expects each configuration's `networking.hostName` to equal its name. Niri desktop
|
||||||
configurations are the exception (`ai-niri` → `ai`, `shoukei-niri` → `shoukei`) and are listed in
|
configurations are the exception (`ai-niri` → `ai`, `shoukei-niri` → `shoukei`) and are listed in
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
outputs,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
vmHosts = [
|
||||||
|
"shoryu"
|
||||||
|
"shushou"
|
||||||
|
"youko"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
lib.mergeAttrsList (
|
||||||
|
map (
|
||||||
|
host:
|
||||||
|
lib.mapAttrs' (
|
||||||
|
guest: _: lib.nameValuePair "${host}/${guest}" true
|
||||||
|
) outputs.nixosConfigurations.${host}.config.microvm.vms
|
||||||
|
) vmHosts
|
||||||
|
)
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
outputs,
|
||||||
|
}:
|
||||||
|
# A VM host must install the guest system that nixosConfigurations evaluates,
|
||||||
|
# the one `just microvm-deploy` ships.
|
||||||
|
let
|
||||||
|
inherit (outputs) nixosConfigurations;
|
||||||
|
# hasInfix matches with a regex, which rejects strings that carry store context.
|
||||||
|
plain = builtins.unsafeDiscardStringContext;
|
||||||
|
vmHosts = [
|
||||||
|
"shoryu"
|
||||||
|
"shushou"
|
||||||
|
"youko"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
lib.mergeAttrsList (
|
||||||
|
map (
|
||||||
|
host:
|
||||||
|
lib.mapAttrs' (
|
||||||
|
guest: _:
|
||||||
|
lib.nameValuePair "${host}/${guest}" (
|
||||||
|
lib.hasInfix (plain "${nixosConfigurations.${guest}.config.system.build.toplevel}") (
|
||||||
|
plain nixosConfigurations.${host}.config.systemd.services."install-microvm-${guest}".script
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) nixosConfigurations.${host}.config.microvm.vms
|
||||||
|
) vmHosts
|
||||||
|
)
|
||||||
Reference in new issue
Block a user