Add nix-snapshotter support to the embedded containerd#13676
Add nix-snapshotter support to the embedded containerd#13676brandond merged 2 commits intok3s-io:mainfrom
Conversation
064ab92 to
5267596
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13676 +/- ##
==========================================
- Coverage 21.79% 21.75% -0.04%
==========================================
Files 191 191
Lines 15539 15556 +17
==========================================
- Hits 3386 3384 -2
- Misses 11702 11721 +19
Partials 451 451
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks for the feedback @brandond! Working through what a test would look like for this snapshotter, as it's admittedly a bit more involved than stargz. Regarding 3: Yes, this works on basically any distro that k3s supports, nix just needs to be installed; similar to a CRI needing to be installed to run OCI images. NixOS is just a meta-distribution built on top of nix and nixpkgs as its build system, package manager, and config store. I'll add a check for nix and the store being available in NixSupported along with adding an integration test. For the test, I'll just install nix into the CI test runner container so it's apparent how this works outside NixOS. |
5267596 to
ad8e8be
Compare
|
Alright, got everything delinted and synced. Also added an integration test that uses the determinant systems nix install action on a new test in the matrix called "nixsnapshotter". It uses nix to build the test image at |
9906d06 to
6004ad7
Compare
|
Ended up changing the test a bit as it didn't work how I expected. Enabled CI on my fork so I could iterate through it and got the tests passing after figuring out the containerd configuration setup for the unpack_config. Also found a general bug in rootless k3s (NRI needs disabling on containerd v3). Tested running nix-snapshotter images on rootless successfully locally. May want to add an integration test for that; an integration test for pulling an OCI image with the nix annotation would be another possible addition. |
6004ad7 to
d11cda8
Compare
|
Fixed the fmt.Errorf lint (:facepalm:). PR checks should be all green now. |
|
Looks like you need a |
I saw that. It's just a go test tools transitive dependency minor version auto bump, between my last tidy and the test run. I can add the bump if you need that to be green. |
|
yes, all the tests need to be green. |
Add support for the "nix" snapshotter, which enables running container images built with nix2container. Nix images reference store paths directly, avoiding layer tarballs and enabling deduplication through the nix store. Changes: - Register nix-snapshotter as a builtin containerd plugin - Add NixSupported() validation (checks nix-store is in PATH) - Configure nix-snapshotter image service proxy in V2/V3 templates with containerd_address for CRI image operations - Add Transfer service unpack_config with differ=walking for multi-arch support - Use containerd state dir for socket path (rootless compatible) - Disable NRI in rootless mode to prevent bind failures Usage: k3s server --snapshotter nix Signed-off-by: Ada <ada@6bit.com> Co-Authored-By: Joshua Perry <josh@6bit.com> Signed-off-by: Ada <ada@6bit.com>
Docker-based integration test that verifies nix-snapshotter works with k3s. The test builds a nix hello image, starts k3s with --snapshotter nix, pulls the image via nix:0 ref, and runs it as a pod, verifying "Hello, world!" output. Signed-off-by: Ada <ada@6bit.com> Co-Authored-By: Joshua Perry <josh@6bit.com> Signed-off-by: Ada <ada@6bit.com>
d11cda8 to
85f325e
Compare
No problema! Bumped |
Proposed Changes
Add the nix-snapshotter plugin to k3s's embedded containerd, enabling rootless k3s with nix-snapshotter. This follows the same integration pattern as the existing stargz snapshotter.
Changes:
builtins_linux.goNixSupported()validation functions for linux and windows"nix"case to snapshotter switch with image service socket configdisable_snapshot_annotations = falsefor nix (required for layer annotations)Usage:
k3s server --snapshotter=nixContext
This revives #9319 (closed as stale), updated for k3s 1.34 and containerd v2.
Key differences from the original PR:
config.go→config_linux.go(matching current k3s structure)templates.gonix-snapshotter is a containerd snapshotter that understands nix store paths natively, enabling fully declarative container images built with Nix. See the architecture docs for details on the image service.
Types of Changes
nix-snapshotteras a Go dependency (1 line in go.mod)nixas a valid snapshotter option for the agentnixsnapshotter, configures it as an image serviceTesting
nix build .#k3sproduces working k3s binary with nix-snapshotter linked inLinked Issues
User-Facing Change
🤖 Generated with Claude Code