Skip to content

Commit b3636b4

Browse files
committed
CI work
1 parent 8f932bf commit b3636b4

4 files changed

Lines changed: 202 additions & 164 deletions

File tree

.github/workflows/test-nixos.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,18 @@ jobs:
5757
echo ""
5858
echo "=== Kernel IP forwarding ==="
5959
cat /proc/sys/net/ipv4/ip_forward
60+
- name: Build nixos test driver
61+
run: nix build --file . nixosTests.containerd.driverInteractive --option sandbox false
62+
6063
- name: Start nixos test (background)
6164
run: |
62-
nix run --file . nixosTests.containerd.driverInteractive --option sandbox false -- --no-interactive > /tmp/test.log 2>&1 &
65+
# The nixos-test-driver uses XDG_RUNTIME_DIR as its temp dir and
66+
# propagates it to VM subprocesses automatically. GHA's default
67+
# XDG_RUNTIME_DIR is /run/user/1001 (1.6 GB tmpfs) which fills up
68+
# quickly — redirect to the root filesystem (87 GB free) instead.
69+
mkdir -p /tmp/nixos-test-tmp
70+
XDG_RUNTIME_DIR=/tmp/nixos-test-tmp \
71+
./result/bin/nixos-test-driver --no-interactive > /tmp/test.log 2>&1 &
6372
echo $! > /tmp/test.pid
6473
echo "Test running in background (PID: $(cat /tmp/test.pid))"
6574
sleep 5

default.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,20 @@ rec {
4242
{
4343
nixkube.cache.enable = false;
4444
nixkube.builders.enable = false;
45+
# push = true retains Nix string context on DaemonSet store paths so
46+
# they become part of the manifest's closure. The NixOS test VM then
47+
# has every path in /nix/store, where nix-serve makes them available
48+
# as a substituter for nixkube's separate /var/lib/nix-csi store.
49+
nixkube.push = true;
4550
nixkube.systems = {
4651
x86_64-linux = true;
4752
aarch64-linux = false;
4853
};
54+
# 10.113.37.1 is the PTP CNI gateway — the host-side veth IP reachable
55+
# from all pods. nix-serve runs there during the NixOS test.
56+
nixkube.node.nixConfig.settings.substituters = [
57+
"http://10.113.37.1:5000?trusted=1"
58+
];
4959
}
5060
];
5161
};

tests/nixos/cluster-module.nix

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
pkgs.kubernetes # kubectl, kubeadm, kubelet
1717
pkgs.cri-tools # crictl
1818
pkgs.helix # editor
19+
pkgs.k9s
20+
pkgs.fish
21+
pkgs.stern
1922
];
2023

2124
environment.variables.EDITOR = "hx";
@@ -47,20 +50,23 @@
4750
};
4851
};
4952

50-
# -- CNI bridge config --
51-
# Simple bridge CNI — no cluster-level setup needed, just this config file.
52-
environment.etc."cni/net.d/10-bridge.conflist".text = builtins.toJSON {
53+
# -- CNI ptp config --
54+
# PTP (point-to-point) CNI: each pod gets a veth pair, no shared bridge.
55+
# Traffic between pods is routed at L3 on the host, which lets kube-proxy
56+
# iptables/ipvs rules see and rewrite service traffic correctly.
57+
environment.etc."cni/net.d/10-ptp.conflist".text = builtins.toJSON {
5358
cniVersion = "1.0.0";
54-
name = "bridge";
59+
name = "ptp";
5560
plugins = [
5661
{
57-
type = "bridge";
58-
bridge = "cni0";
59-
isGateway = true;
62+
type = "ptp";
6063
ipMasq = true;
6164
ipam = {
6265
type = "host-local";
63-
ranges = [ [ { subnet = "10.244.0.0/16"; } ] ];
66+
subnet = "10.113.37.0/24";
67+
# Explicit gateway ensures the host-side veth always gets this IP,
68+
# which nixkube pods use to reach nix-serve on the VM.
69+
gateway = "10.113.37.1";
6470
routes = [ { dst = "0.0.0.0/0"; } ];
6571
};
6672
}
@@ -135,10 +141,30 @@
135141
# -- VM sizing for kubeadm cluster --
136142
virtualisation = {
137143
memorySize = 4096;
138-
diskSize = 10240;
144+
diskSize = 30720; # 30GB: 20GB system + 8GB swap + headroom
139145
cores = 4;
140146
};
141147

148+
# Increase 9p max packet size for Nix store mounts (default 16 KB is slow).
149+
virtualisation.msize = 131072;
150+
151+
152+
# Swap so the 10GB tmpfs below can exceed physical RAM without OOM.
153+
swapDevices = [
154+
{
155+
device = "/swapfile";
156+
size = 8192; # 8GB in MiB
157+
}
158+
];
159+
160+
# nixkube's initContainer copies the full node-env closure here — potentially
161+
# several GB. Keeping it on tmpfs avoids thrashing the qcow2 disk image.
162+
fileSystems."/var/lib/nix-csi" = {
163+
device = "tmpfs";
164+
fsType = "tmpfs";
165+
options = [ "size=10g" "mode=755" ];
166+
};
167+
142168
# -- Interactive debug user --
143169
users.users.nixkube = {
144170
isNormalUser = true;
@@ -160,6 +186,16 @@
160186
"d /var/run/nri 0755 root root -"
161187
];
162188

189+
# Serve the VM's /nix/store as an unsigned binary cache on port 5000.
190+
# nixkube pods use this as a trusted substituter so test workload paths can be
191+
# fetched without going to the internet (paths pre-populated via additionalPaths).
192+
services.nix-serve = {
193+
enable = true;
194+
package = pkgs.nix-serve-ng;
195+
bindAddress = "0.0.0.0";
196+
port = 5000;
197+
};
198+
163199
# Enable external networking for image pulls and nix binary cache access
164200
# SLiRP provides DHCP + DNS automatically
165201
networking.firewall.enable = false;

0 commit comments

Comments
 (0)