diff options
| author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-06-05 03:56:44 +0000 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-06-12 02:58:55 +0000 |
| commit | 092f66d511ac303a73fb0853314d792dde69cd28 (patch) | |
| tree | 235ca5387443aa3c3a0df04a89962da30282cb4e | |
| parent | 93440a018d098f34f0c8f6c1a4ad8c66a914c225 (diff) | |
| download | meta-virtualization-092f66d511ac303a73fb0853314d792dde69cd28.tar.gz | |
k3s: fix pause image reference for containerd v2
K3s's default pause image reference "rancher/mirrored-pause:3.6" is a
short name that containerd v1 auto-expanded to the fully qualified
"docker.io/rancher/mirrored-pause:3.6". The k3s v1.36 uprev moved to
containerd v2, which uses a new CRI plugin (io.containerd.cri.v1) with
a pinned_images config instead of the old sandbox_image. Containerd v2
no longer auto-expands short names when looking up pinned images,
causing every pod sandbox creation to fail with "image not found" even
though the image is present in the containerd image store under its
fully qualified name.
Pass --pause-image docker.io/rancher/mirrored-pause:3.6 in both the
server and agent systemd service files to use the fully qualified
reference that containerd v2 can resolve.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
| -rw-r--r-- | recipes-containers/k3s/k3s/k3s-agent.service | 4 | ||||
| -rw-r--r-- | recipes-containers/k3s/k3s/k3s.service | 5 | ||||
| -rw-r--r-- | tests/test_k3s_runtime.py | 11 |
3 files changed, 15 insertions, 5 deletions
diff --git a/recipes-containers/k3s/k3s/k3s-agent.service b/recipes-containers/k3s/k3s/k3s-agent.service index 0304d640..4962555c 100644 --- a/recipes-containers/k3s/k3s/k3s-agent.service +++ b/recipes-containers/k3s/k3s/k3s-agent.service | |||
| @@ -31,6 +31,8 @@ ExecStartPre=-/sbin/modprobe overlay | |||
| 31 | # controller populates this after joining, but the CNI plugin needs | 31 | # controller populates this after joining, but the CNI plugin needs |
| 32 | # the file to exist at sandbox creation time | 32 | # the file to exist at sandbox creation time |
| 33 | ExecStartPre=/bin/sh -c 'mkdir -p /run/flannel && test -f /run/flannel/subnet.env || echo "FLANNEL_NETWORK=10.42.0.0/16\nFLANNEL_SUBNET=10.42.0.1/24\nFLANNEL_MTU=1450\nFLANNEL_IPMASQ=true" > /run/flannel/subnet.env' | 33 | ExecStartPre=/bin/sh -c 'mkdir -p /run/flannel && test -f /run/flannel/subnet.env || echo "FLANNEL_NETWORK=10.42.0.0/16\nFLANNEL_SUBNET=10.42.0.1/24\nFLANNEL_MTU=1450\nFLANNEL_IPMASQ=true" > /run/flannel/subnet.env' |
| 34 | ExecStart=/usr/local/bin/k3s agent | 34 | # Containerd v2's CRI plugin requires the fully qualified image reference |
| 35 | # for the sandbox (pause) image. See k3s.service for details. | ||
| 36 | ExecStart=/usr/local/bin/k3s agent --pause-image docker.io/rancher/mirrored-pause:3.6 | ||
| 35 | ExecStopPost=/usr/local/bin/k3s-clean | 37 | ExecStopPost=/usr/local/bin/k3s-clean |
| 36 | 38 | ||
diff --git a/recipes-containers/k3s/k3s/k3s.service b/recipes-containers/k3s/k3s/k3s.service index e7402867..5e823260 100644 --- a/recipes-containers/k3s/k3s/k3s.service +++ b/recipes-containers/k3s/k3s/k3s.service | |||
| @@ -34,7 +34,10 @@ ExecStartPre=-/sbin/modprobe overlay | |||
| 34 | # Create flannel subnet.env if not present — k3s's embedded flannel | 34 | # Create flannel subnet.env if not present — k3s's embedded flannel |
| 35 | # controller expects this file for CNI plugin configuration | 35 | # controller expects this file for CNI plugin configuration |
| 36 | ExecStartPre=/bin/sh -c 'mkdir -p /run/flannel && test -f /run/flannel/subnet.env || echo "FLANNEL_NETWORK=10.42.0.0/16\nFLANNEL_SUBNET=10.42.0.1/24\nFLANNEL_MTU=1450\nFLANNEL_IPMASQ=true" > /run/flannel/subnet.env' | 36 | ExecStartPre=/bin/sh -c 'mkdir -p /run/flannel && test -f /run/flannel/subnet.env || echo "FLANNEL_NETWORK=10.42.0.0/16\nFLANNEL_SUBNET=10.42.0.1/24\nFLANNEL_MTU=1450\nFLANNEL_IPMASQ=true" > /run/flannel/subnet.env' |
| 37 | ExecStart=/usr/local/bin/k3s server | 37 | # Containerd v2's CRI plugin requires the fully qualified image reference |
| 38 | # for the sandbox (pause) image. The k3s default "rancher/mirrored-pause:3.6" | ||
| 39 | # is a short name that containerd v2 cannot resolve from its image store. | ||
| 40 | ExecStart=/usr/local/bin/k3s server --pause-image docker.io/rancher/mirrored-pause:3.6 | ||
| 38 | # Avoid any delay due to this service when the system is rebooting or shutting | 41 | # Avoid any delay due to this service when the system is rebooting or shutting |
| 39 | # down by using the k3s-killall.sh script to kill all of the running k3s | 42 | # down by using the k3s-killall.sh script to kill all of the running k3s |
| 40 | # services and containers | 43 | # services and containers |
diff --git a/tests/test_k3s_runtime.py b/tests/test_k3s_runtime.py index 662bdf4c..d26b9164 100644 --- a/tests/test_k3s_runtime.py +++ b/tests/test_k3s_runtime.py | |||
| @@ -419,9 +419,13 @@ def k3s_multinode(request, poky_dir, build_dir, machine, k3s_image): | |||
| 419 | 419 | ||
| 420 | rootfs_orig = ext4_files[-1] | 420 | rootfs_orig = ext4_files[-1] |
| 421 | 421 | ||
| 422 | # Create a copy of the rootfs for the agent VM — two VMs can't | 422 | # Both VMs need their own rootfs copy — the original may still be |
| 423 | # share the same ext4 file read-write | 423 | # locked by a previous runqemu session (single-node test), and two |
| 424 | # VMs can't share the same ext4 file read-write. | ||
| 425 | rootfs_server = Path(f"/tmp/k3s-server-rootfs-{os.getpid()}.ext4") | ||
| 424 | rootfs_agent = Path(f"/tmp/k3s-agent-rootfs-{os.getpid()}.ext4") | 426 | rootfs_agent = Path(f"/tmp/k3s-agent-rootfs-{os.getpid()}.ext4") |
| 427 | print(f"Copying rootfs for server VM: {rootfs_orig} -> {rootfs_server}") | ||
| 428 | shutil.copy2(rootfs_orig, rootfs_server) | ||
| 425 | print(f"Copying rootfs for agent VM: {rootfs_orig} -> {rootfs_agent}") | 429 | print(f"Copying rootfs for agent VM: {rootfs_orig} -> {rootfs_agent}") |
| 426 | shutil.copy2(rootfs_orig, rootfs_agent) | 430 | shutil.copy2(rootfs_orig, rootfs_agent) |
| 427 | 431 | ||
| @@ -438,7 +442,7 @@ def k3s_multinode(request, poky_dir, build_dir, machine, k3s_image): | |||
| 438 | use_kvm=use_kvm, timeout=timeout, | 442 | use_kvm=use_kvm, timeout=timeout, |
| 439 | extra_qemu_params=server_params, | 443 | extra_qemu_params=server_params, |
| 440 | use_runqemu=False, | 444 | use_runqemu=False, |
| 441 | rootfs_path=rootfs_orig, | 445 | rootfs_path=rootfs_server, |
| 442 | kernel_append="k3s.role=server k3s.node-ip=192.168.50.1", | 446 | kernel_append="k3s.role=server k3s.node-ip=192.168.50.1", |
| 443 | log_suffix="-server") | 447 | log_suffix="-server") |
| 444 | 448 | ||
| @@ -454,6 +458,7 @@ def k3s_multinode(request, poky_dir, build_dir, machine, k3s_image): | |||
| 454 | rootfs_path=rootfs_agent, | 458 | rootfs_path=rootfs_agent, |
| 455 | kernel_append="k3s.role=agent k3s.node-ip=192.168.50.2 k3s.node-name=k3s-agent", | 459 | kernel_append="k3s.role=agent k3s.node-ip=192.168.50.2 k3s.node-name=k3s-agent", |
| 456 | log_suffix="-agent") | 460 | log_suffix="-agent") |
| 461 | server._rootfs_copy = str(rootfs_server) | ||
| 457 | agent._rootfs_copy = str(rootfs_agent) | 462 | agent._rootfs_copy = str(rootfs_agent) |
| 458 | 463 | ||
| 459 | try: | 464 | try: |
