suse-edge / edge-image-builder

Tool for creating and configuring a set of images to automate the deployment of Edge environments
Apache License 2.0
55 stars 28 forks source link

How to add config template for containerd before RKE2 starts ? #587

Closed jomeier closed 1 month ago

jomeier commented 1 month ago

Hi,

I desperately try to get a custom

config.toml.tmpl

file in the directory

/var/lib/rancher/rke2/agent/etc/containerd

before the rke2 installation scripts starts.

I tried to use a custom script. In that I created the path /var/lib/rancher/rke2/agent/etc/containerd before and copied the config.toml.tmpl file in that directory.

My second method was to create a folder and config file:

os-files/var/lib/rancher/rke2/agent/etc/containerd/config.toml.tmpl

After all that methods the config.toml.tmpl file is still missing in the /var/lib/rancher/rke2/agent/etc/containerd directory after the first boot.

How can I do that?

I need that config change for containerd to get CDI with Kubevirt running on block devices.

Thanks a lot for your assistance, Josef

e-minguez commented 1 month ago

Can you try adding a custom script instead? https://github.com/suse-edge/edge-image-builder/blob/main/docs/building-images.md#custom You can (ab)use the script to be executed before the RKE2 installation one to do those changes. Something like 40-custom-containerd-config.sh where it creates the folder and the file:

#!/bin/bash
mkdir -p /var/lib/rancher/rke2/agent/etc/containerd
cat << EOF > /var/lib/rancher/rke2/agent/etc/containerd/config.toml.tmpl
<your content>
EOF
chmod 644 /var/lib/rancher/rke2/agent/etc/containerd/config.toml.tmpl

(I didn't tested this, consider this as 'pseudo-code')

atanasdinov commented 1 month ago

@e-minguez He already said he tried to use a custom script.

@jomeier Please try to mount /var before storing the file and unmounting it after (via umount /var) in your custom script. The issue is /var isn't mounted by default during combustion. Related: https://github.com/suse-edge/edge-image-builder/issues/526

jomeier commented 1 month ago

@e-minguez He already said he tried to use a custom script.

@jomeier Please try to mount /var before storing the file and unmounting it after (via umount /var) in your custom script. The issue is /var isn't mounted by default during combustion. Related: #526

Yes that worked! I didn't mount /var but got no error message while writing to it :D Thanks a lot!