Skip to content

Commit 69dac2c

Browse files
Merge pull request #301 from shirok1/fix-node-installer-containerd-2
node-installer: fixes for containerd 2
2 parents cf4c845 + e513c36 commit 69dac2c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

node-installer/script/installer.sh

+10-7
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ if pgrep -f snap/microk8s > /dev/null; then
2323
fi
2424
elif ls $NODE_ROOT/var/lib/rancher/rke2/agent/etc/containerd/config.toml > /dev/null 2>&1 ; then
2525
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
2826
elif ls $NODE_ROOT/var/lib/rancher/k3s/agent/etc/containerd/config.toml > /dev/null 2>&1 ; then
2927
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
3228
elif pgrep -f /var/lib/k0s/bin/kubelet > /dev/null; then
3329
IS_K0S_WORKER=true
3430
CONTAINERD_CONF=/etc/k0s/containerd.d/spin.toml
@@ -67,9 +63,16 @@ mkdir -p $NODE_ROOT$KWASM_DIR/bin/
6763

6864
cp /assets/containerd-shim-spin-v2 $NODE_ROOT$KWASM_DIR/bin/
6965

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
7174
echo "Adding Spin runtime to containerd"
72-
if $IS_K3S; then
75+
if grep -q "version = 3" $NODE_ROOT$CONTAINERD_CONF; then
7376
echo '
7477
[plugins."io.containerd.cri.v1.runtime".containerd.runtimes."spin"]
7578
runtime_type = "'$KWASM_DIR'/bin/containerd-shim-spin-v2"
@@ -88,7 +91,7 @@ fi
8891
# configure SystemdCgroup
8992
if ! grep -q 'runtimes.spin.options' $NODE_ROOT$CONTAINERD_CONF && [ "$SYSTEMD_CGROUP" = "true" ]; then
9093
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
9295
echo '
9396
[plugins."io.containerd.cri.v1.runtime".containerd.runtimes.spin.options]
9497
SystemdCgroup = '$SYSTEMD_CGROUP'

0 commit comments

Comments
 (0)