Skip to content

Commit 3498603

Browse files
committed
CI work
1 parent 8f932bf commit 3498603

3 files changed

Lines changed: 197 additions & 163 deletions

File tree

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: 50 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,35 @@
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+
# Build an erofs image of /nix/store at VM startup instead of serving it
149+
# over 9p. erofs is a highly-efficient read-only filesystem; kubeadm,
150+
# kubelet and containerd all do heavy store reads so this is a big win.
151+
virtualisation.useNixStoreImage = true;
152+
153+
# Increase 9p max packet size for any remaining 9p mounts (default 16 KB).
154+
virtualisation.msize = 131072;
155+
156+
157+
# Swap so the 10GB tmpfs below can exceed physical RAM without OOM.
158+
swapDevices = [
159+
{
160+
device = "/swapfile";
161+
size = 8192; # 8GB in MiB
162+
}
163+
];
164+
165+
# nixkube's initContainer copies the full node-env closure here — potentially
166+
# several GB. Keeping it on tmpfs avoids thrashing the qcow2 disk image.
167+
fileSystems."/var/lib/nix-csi" = {
168+
device = "tmpfs";
169+
fsType = "tmpfs";
170+
options = [ "size=10g" "mode=755" ];
171+
};
172+
142173
# -- Interactive debug user --
143174
users.users.nixkube = {
144175
isNormalUser = true;
@@ -160,6 +191,16 @@
160191
"d /var/run/nri 0755 root root -"
161192
];
162193

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

0 commit comments

Comments
 (0)