@@ -23,12 +23,8 @@ if pgrep -f snap/microk8s > /dev/null; then
23
23
fi
24
24
elif ls $NODE_ROOT /var/lib/rancher/rke2/agent/etc/containerd/config.toml > /dev/null 2>&1 ; then
25
25
IS_RKE2_AGENT=true
26
- cp $NODE_ROOT /var/lib/rancher/rke2/agent/etc/containerd/config.toml $NODE_ROOT /var/lib/rancher/rke2/agent/etc/containerd/config.toml.tmpl
27
- CONTAINERD_CONF=/var/lib/rancher/rke2/agent/etc/containerd/config.toml.tmpl
28
26
elif ls $NODE_ROOT /var/lib/rancher/k3s/agent/etc/containerd/config.toml > /dev/null 2>&1 ; then
29
27
IS_K3S=true
30
- cp $NODE_ROOT /var/lib/rancher/k3s/agent/etc/containerd/config.toml $NODE_ROOT /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl
31
- CONTAINERD_CONF=/var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl
32
28
elif pgrep -f /var/lib/k0s/bin/kubelet > /dev/null; then
33
29
IS_K0S_WORKER=true
34
30
CONTAINERD_CONF=/etc/k0s/containerd.d/spin.toml
@@ -67,9 +63,16 @@ mkdir -p $NODE_ROOT$KWASM_DIR/bin/
67
63
68
64
cp /assets/containerd-shim-spin-v2 $NODE_ROOT$KWASM_DIR /bin/
69
65
70
- if ! grep -q spin $NODE_ROOT$CONTAINERD_CONF ; then
66
+ # A bug in containerd makes BinaryName not work with shim not in PATH, so this statically links the kwasm installation to path
67
+ # https://github.com/containerd/containerd/issues/11480
68
+ mkdir -p $NODE_ROOT /usr/local/bin/
69
+ ln -s $KWASM_DIR /bin/containerd-shim-spin-v2 $NODE_ROOT /usr/local/bin/containerd-shim-spin
70
+
71
+ # K3S and RKE2 can detect spin shim themselves, no need to configure
72
+ # https://github.com/k3s-io/k3s/pull/9519
73
+ if ! ( $IS_K3S || $IS_RKE2_AGENT ) && ! grep -q spin $NODE_ROOT$CONTAINERD_CONF ; then
71
74
echo " Adding Spin runtime to containerd"
72
- if $IS_K3S ; then
75
+ if grep -q " version = 3 " $NODE_ROOT$CONTAINERD_CONF ; then
73
76
echo '
74
77
[plugins."io.containerd.cri.v1.runtime".containerd.runtimes."spin"]
75
78
runtime_type = "' $KWASM_DIR ' /bin/containerd-shim-spin-v2"
88
91
# configure SystemdCgroup
89
92
if ! grep -q ' runtimes.spin.options' $NODE_ROOT$CONTAINERD_CONF && [ " $SYSTEMD_CGROUP " = " true" ]; then
90
93
echo " Setting SystemdCgroup to $SYSTEMD_CGROUP in Spin containerd configuration"
91
- if $IS_K3S ; then
94
+ if grep -q " version = 3 " $NODE_ROOT$CONTAINERD_CONF ; then
92
95
echo '
93
96
[plugins."io.containerd.cri.v1.runtime".containerd.runtimes.spin.options]
94
97
SystemdCgroup = ' $SYSTEMD_CGROUP '
0 commit comments