k3s binary installer and shared-containerd wiring for OpenCharly images.
The k3s candy downloads the k3s multi-call binary (sha256-verified against the
release manifest) to /usr/local/bin/k3s and symlinks kubectl, crictl, and
ctr onto it (k3s dispatches on argv[0]). It also installs the runtime
dependencies kube-proxy and the apiserver tunnel need — iptables, conntrack,
socat, ethtool, and ca-certificates — via the distro package manager, not
the upstream curl | sh installer.
The k3s-shared-containerd candy composes that binary and points k3s at the ONE
shared containerd instead of letting k3s start its embedded one.
Neither candy starts a service. Role selection happens in k3s-server and
k3s-agent, which wrap this binary with the right CLI verb.
| Property | k3s |
k3s-shared-containerd |
|---|---|---|
| Binary | /usr/local/bin/k3s (symlinks: kubectl, crictl, ctr) |
inherits k3s |
| Pinned version | v1.37.0+k3s1 |
inherits k3s |
| Packages | ca-certificates, ethtool, fuse-overlayfs, socat + per-distro iptables/conntrack |
none of its own |
| Install files | charly.yml (run: step) |
charly.yml (write: steps) |
| Service / port | none | none |
| Shared daemon | — | /run/containerd/containerd.sock (not started here) |
Typically not used directly — compose /charly-infrastructure:k3s-server or
/charly-infrastructure:k3s-agent, which depend on this candy. For a bare
binary-only image, pin this repo in a box's candy: list:
k3s-base:
candy:
base: fedora
candy:
- '@github.com/opencharly/layer-k3s:v2026.293.0040'Compose k3s-shared-containerd on a host image that already runs the rootful
shared daemon (containerd-host):
k3s-shared:
candy:
base: cachyos
candy:
- k3s-shared-containerdThe layer installs:
/etc/rancher/k3s/config.yamlwithcontainer-runtime-endpoint: unix:///run/containerd/containerd.sock. k3s then uses the shared image store and snapshotter; it starts no bundled containerd./etc/containerd/conf.d/50-k3s-cni.toml— a partial containerd config carrying only the two k3s-specific CNI keys:bin_dirs = ["/var/lib/rancher/k3s/data/current/bin"]andconf_dir = "/var/lib/rancher/k3s/agent/etc/cni/net.d". Without them pods start but have no network. The shared daemon's own config (version = 4,imports = ["/etc/containerd/conf.d/*.toml"], thecrun/krun/nvidiahandlers) is owned by the containerd-host image, never by this layer./var/lib/rancher/k3s/server/manifests/krun-runtimeclass.yamlandnvidia-runtimeclass.yaml— declarativenode.k8s.io/v1RuntimeClasses (handler: krun,handler: nvidia). k3s auto-applies everything in that directory, so no imperativekubectl applyis needed. The handlers themselves live in the shared containerd's CRI config.
After the image is built:
/usr/local/bin/k3s --version # k3s version v1.37.0+k3s1
/usr/local/bin/kubectl version --client
grep container-runtime-endpoint /etc/rancher/k3s/config.yamlk3s asks the CRI for its runtime set (and cgroup driver) once, at start. A
handler added to the shared containerd later — for example the nvidia handler
written by the NVIDIA toolkit — is invisible to kubelet until k3s restarts.
The layer installs /usr/local/bin/k3s-runtime-handler-guard. Its run: step
executes at install time and on every later application of the layer. The guard
is a no-op where the shared daemon's socket does not exist (an image build, or a
host that has not started containerd): there is nothing to fingerprint. Where
the socket does exist it records the fingerprint of the merged containerd CRI
runtime map; because the install step runs before k3s starts, that baseline is
the set the server latches. On later applications it restarts k3s only when the
fingerprint changed while k3s was running; if k3s was not running it updates the
baseline, and the next start latches the new set. On the first application while
k3s is already running it restarts once, because that k3s latched a set older
than this layer. If a handler is added outside a charly run, restart k3s
explicitly:
sudo systemctl restart k3scheck-k3s-shared-containerd is the three-step proof — absence, perform,
presence — of this layer on a disposable containerd-host venue:
absent-before— k3s is not running and nokrunRuntimeClass is served.perform-start— start k3s from the config this layer installed.present-after— the node is Ready oncontainerd://2.x, k3s's pods are visible innerdctl -n k8s.io pson the SHARED socket (the proof it is not the embedded daemon), and both RuntimeClasses are served.guard-idempotent— the handler guard has a baseline for the running unit and does not restart k3s when the handler set is unchanged.
It is a host: local bed, so run it inside the disposable venue:
charly --host <containerd-host-vm> check run check-k3s-shared-containerdNever run it on an operator workstation: the layer writes /etc, installs the
k3s binary, and starts a control plane.
charly.yml— thek3s:candy (verified binary install), thek3s-shared-containerd:candy (shared-containerd wiring), thek3s-shared-containerd-app:local template, thecheck-k3s-shared-containerd:bed, and the embeddedk3s-skill:entity.files/k3s-runtime-handler-guard.sh— the installed handler guard.test/k3s-runtime-handler-guard-test.sh— its branch regression test (bash test/k3s-runtime-handler-guard-test.sh)..agents/skills/k3s/SKILL.md— the owning skill body..github/workflows/tag-on-merge.yml— CalVer tag +CHANGELOG/on merge.README.md— this user overview.
- Owning skill:
/charly-infrastructure:k3s— the binary installer and the shared-containerd contract - Role candies:
/charly-infrastructure:k3s-server,/charly-infrastructure:k3s-agent - Canonical contracts:
K3S.md§1, §2, §4, §5 andCONTAINERD-IMAGES.md§1.7 in theopencharly/opencharlyumbrella - Operator tooling:
/charly-coder:kubernetes-layer(distrokubectl/helm) - Cluster probe verb:
/charly-kubernetes:check-k8s opencharly/charly— the charly CLI and image builder