Skip to content

pynixd: Kubernetes builder pools (pods that join by ticket; nested, krun and nixkube-input kinds) #1560

Open

Description

@Lillecarl

pynixd's provisioner gets a kubernetes provider: a builder is a pod that joins by its ticket over reverse SSH, as EC2, GHA and NoMac builders do. Tested on a kubeadm cluster in vivarium.

Decisions (User, 2026-11-21):

  • The provider coexists with nixkube's builder_manager.py; nixkube is unchanged.
  • It lives in pynixd core (pynixd/provisioning/kubernetes.py); kr8s becomes a pynixd dependency.
  • No clock work in any kind. Nix's "1970" is the store mtime (posix-fs-canonicalise.cc:13, mtimeStore = 1), which pynixd's canonicalise already sets. A time namespace offsets only CLOCK_MONOTONIC and CLOCK_BOOTTIME (time_namespaces(7)).

Kinds, a template field each:

  1. nested: a single-use pod (one slot) whose pynixd builds in its own namespace sandbox, nested in the pod's.
  2. krun: the same pod with /dev/kvm; pynixd's build_vm (pynixd: build in a libkrun microVM, with the store as an allowlisted DAX share #1186). Needs a QEMU guest with nested virtualization.
  3. nixkube inputs (spike): nixkube mounts the input closure into one container, and a sidecar runs the builder in that container's namespaces. Provider.launch never sees the derivation, so this kind needs another seam: a store whose BuildDerivation creates the pod. NRI 0.11 can adjust namespaces, sysctl and seccomp (api.proto:553); whether our containerd applies them is not yet measured.

Provider shape: the ticket goes in a Secret owned by the pod; the pod name comes from the instance id, so AlreadyExists replays a lost answer; tags go in labels (escaped to label syntax) and annotations.

Order: provider + kind 1 with its vivarium test, then kind 2, then the kind 3 spike.


Assisted-By: Claude Opus 5.5

Activity

  1. added
    source: pynixd
    on Nov 21, 2026
  2. Lillecarl commented on Nov 21, 2026

    @Lillecarl
    ContributorAuthor

    Two decisions from User, 2026-11-21:

    • builder_manager coexists for now. It is likely replaced once these kinds prove themselves, so the template takes a whole pod (a nixkube CSI store volume included).
    • The nixkube-inputs kind need not run Nix's builder. Its likely path is the builder parts of daemonless pynixd (pynixd_store/builder), driven from the communicating container. Whether it works at all is still open.

    Assisted-By: Claude Opus 5.5

  3. Lillecarl commented on Nov 21, 2026

    @Lillecarl
    ContributorAuthor

    The krun kind landed (main 654e950): internal.tests.provisioning-kubernetes-krun, one kubeadm QEMU node with nested KVM.

    • The pod's store sets build_vm, op_routes.BuildDerivation = "pynixd" and pynixd_writes = true. Without pynixd_writes, the pod's pynixd refuses to start.
    • The build wrote kernel 6.12.91 (libkrunfw's); the node runs 7.2.9. It built in 12 s, and the single-use pod ended used. Negative control without build_vm: the build ran under 7.2.9 and the phase fails.
    • The pod is still privileged for /dev/kvm. A KVM device plugin would narrow that.
    • No nightly step: it needs nested KVM, which a GHA runner may lack. Unmeasured.

    Found on the way: the provisioner dropped Machine.error, so a pod that failed at start showed only as gone rows. It now warns provisioning_machine_failed, and the UML test's broken phase checks it. Each Kubernetes API call is now bounded at 30 s, because kr8s sets no timeout.


    Assisted-By: Claude Opus 5.5

  4. Lillecarl commented on Nov 22, 2026

    @Lillecarl
    ContributorAuthor

    Build pod throughput and input delivery, measured on one UML node (1 CPU), bookmark spike/pod-build (pszxnrqk).

    Per build. A pod that runs true starts in 2.2 s (7.8 s when 5 start at once). A build pod costs about 15.6 s fixed, plus 29 ms per MiB of input over SSH. One busybox build on an idle node took 11.9 s: pod to first log line 3.8 s (kubelet 1.4, Python 2.4), Server start in the pod 2.8 s (managed nix daemon, system probe builds, 16 schema migrations, SSH 0.6), inputs 1.4 s, build 1.3 s, push and end 2.6 s. The fixed part is the target, not input delivery.

    Inputs, pynixd's closure (132 paths, 378 MiB). Bind each path as the helper does: 21 ms, the same on the node, in a pod and in a hostUsers: false pod. Overlay with the node store as lower layer: 0.1 ms plus 2.3 ms of first lookups, but it shows the whole store, unlike Nix. Hard link tree: 0.94 s. composefs without digests: dump 1.21 s, mkcomposefs 0.18 s, mount 5 ms. nix copy into a new store: 4.1 s. With the inputs in the node store, delivery costs milliseconds. The cost moves to one fill of the node store per node, not one copy per build.

    Admission. restricted and baseline both refuse a hostPath store. A CSI store passes restricted for the plain pod and baseline for the user-namespaced pod. So the node store reaches a pod through CSI or NRI.


    Assisted-By: Claude Opus 5.5

  5. Lillecarl commented on Nov 22, 2026

    @Lillecarl
    ContributorAuthor

    Correction and QEMU numbers for the comment above. UML is the fallback backend; these figures replace the UML ones.

    QEMU, 16 CPUs (run qbench1). A true pod starts in 1.4 s (3.0 s when 5 start at once). Build pods: busybox 5.8 s, python3 7.1 s, pynixd 9.7 s, so about 5.4 s fixed plus 11 ms per MiB. pynixd's closure: bind each path 4.3 ms (the same in both pods), overlay 0.1 ms, hard links 0.36 s, composefs 1.0 s (dump 0.95, mkcomposefs 0.06, mount 0.3 ms), nix copy 2.4 s.

    Correction. The system probe builds and the schema migrations take about 0.3 s together; they are not the fixed cost. From one UML sample, the gaps are: pod create to pynixd's first log line, pod shutdown to the client's result, the managed nix daemon start (about 0.9 s), and SSH (0.6 s).

    Unverified. "Admitted" is a dry run without a CSI driver installed. A CSI store in a hostUsers: false pod is not mounted yet, and NRI delivery is not measured. The in-pod timings used the test's hostPath store. The full test passes on QEMU (all 12 phases).


    Assisted-By: Claude Opus 5.5

  6. Lillecarl commented on Nov 22, 2026

    @Lillecarl
    ContributorAuthor

    Spike (spike/pod-build, not landed): a build pod reads its inputs from a farm, in place.

    • lower_store on a local store: an immutable store under it, opened read-only and immutable. Its paths are valid in the pod's store in /build, and their files stay in the farm. No OverlayFS. Needs daemon = false.
    • The builder's binds, the recursive-nix restriction and the NAR dump read a lower path's files from the farm (StoreEngine.files_of). Writes stay in /build.
    • Measured on QEMU (provk-qfull4, all 14 phases pass): the same build with busybox as its input copied 39552408 bytes in from central on the plain build pod, and 0 bytes on the farm pod. The farm's database held 174 paths, the same as its store.
    • Found on the way: a Nix 2.35 farm keys realisations by path (BuildTraceV3), and a pod's 2.34 asks by hash (Realisations). The engine asks the farm only for a keying whose table it holds.
    • Found on the way: central read a preempted pod only after its log ended, and the pod could be gone by then ("deleted with exit None and no result"). Central now watches each build pod from its creation.

    Not yet proven: the CSI farm itself (one bind mount per path, in the sandbox's user namespace). The test stands in a plain directory for it.


    Assisted-By: Claude Opus 5.5

  7. Lillecarl commented on Nov 23, 2026

    @Lillecarl
    ContributorAuthor

    Follow-up: the CSI farm is now proven too (spike, nixkube buildpods phase, QEMU run nkfarmbuild6).

    A pod whose whole /nix is a nixkube farm volume (presentation: farm: one read-only bind per path, plus the closure's database) runs pynixd as uid 1000 with no capability. pynixd loaded the farm's 171 paths as its lower store. The sandbox container bound the farm's busybox into the build, and the build passed. No central took part, so nothing reached the pod from elsewhere.

    Trap for later: a Nix client on the pod's Unix socket cannot build there. It reads a .drv and an input from one store directory, and the pod keeps them in two. build-one drives pynixd in process, so a real build pod is not affected.


    Assisted-By: Claude Opus 5.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    source: pynixd

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions