From f5a9aaa10081c3a40cb71de49721ff548b296391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Tue, 26 Nov 2024 14:01:50 +0100 Subject: [PATCH 1/2] kata-deploy: Support containerd config version 3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Ubuntu 24.04, with the distro default containerd, we're already getting: ``` $ containerd config default | grep "version = " version = 3 ``` With that in mind, let's make sure that we're ready to support this from the next release. Signed-off-by: Fabiano FidĂȘncio --- tools/packaging/kata-deploy/scripts/kata-deploy.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 1835488c2a..c6613099a8 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -497,6 +497,10 @@ function configure_containerd_runtime() { pluginid=\"io.containerd.grpc.v1.cri\" fi + if grep -q "version = 3\>" $containerd_conf_file; then + pluginid=\"io.containerd.cri.v1.runtime\" + fi + local runtime_table=".plugins.${pluginid}.containerd.runtimes.\"${runtime}\"" local runtime_options_table="${runtime_table}.options" local runtime_type=\"io.containerd."${runtime}".v2\" From 6f70ab916982629d5b1371d15764489673b70725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Tue, 26 Nov 2024 14:11:38 +0100 Subject: [PATCH 2/2] kata-deploy: Adapt how the containerd version is checked for k0s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's actually mount the whole /etc/k0s as /etc/containerd, so we can easily access the containerd configuration file which has the version in it, allowing us to parse it instead of just making a guess based on kubernetes distro being used. Signed-off-by: Fabiano FidĂȘncio --- .../kata-deploy/overlays/k0s/mount_k0s_conf.yaml | 2 +- .../packaging/kata-deploy/scripts/kata-deploy.sh | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/packaging/kata-deploy/kata-deploy/overlays/k0s/mount_k0s_conf.yaml b/tools/packaging/kata-deploy/kata-deploy/overlays/k0s/mount_k0s_conf.yaml index c10f938f85..d8b7245fe7 100644 --- a/tools/packaging/kata-deploy/kata-deploy/overlays/k0s/mount_k0s_conf.yaml +++ b/tools/packaging/kata-deploy/kata-deploy/overlays/k0s/mount_k0s_conf.yaml @@ -9,4 +9,4 @@ spec: volumes: - name: containerd-conf hostPath: - path: /etc/k0s/containerd.d/ \ No newline at end of file + path: /etc/k0s/ diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index c6613099a8..3bb5931bee 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -491,13 +491,16 @@ function configure_containerd_runtime() { local configuration="configuration-${shim}" local pluginid=cri - # if we are running k0s auto containerd.toml generation, the base template is by default version 2 - # we can safely assume to reference the newer version of cri - if grep -q "version = 2\>" $containerd_conf_file || [ "$1" == "k0s-worker" ] || [ "$1" == "k0s-controller" ]; then + local containerd_root_conf_file="$containerd_conf_file" + if [[ "$1" =~ ^(k0s-worker|k0s-controller)$ ]]; then + containerd_root_conf_file="/etc/containerd/containerd.toml" + fi + + if grep -q "version = 2\>" $containerd_root_conf_file; then pluginid=\"io.containerd.grpc.v1.cri\" fi - if grep -q "version = 3\>" $containerd_conf_file; then + if grep -q "version = 3\>" $containerd_root_conf_file; then pluginid=\"io.containerd.cri.v1.runtime\" fi @@ -697,7 +700,8 @@ function main() { # From 1.27.1 onwards k0s enables dynamic configuration on containerd CRI runtimes. # This works by k0s creating a special directory in /etc/k0s/containerd.d/ where user can drop-in partial containerd configuration snippets. # k0s will automatically pick up these files and adds these in containerd configuration imports list. - containerd_conf_file="/etc/containerd/kata-containers.toml" + containerd_conf_file="/etc/containerd/containerd.d/kata-containers.toml" + containerd_conf_file_backup="${containerd_conf_tmpl_file}.bak" fi # only install / remove / update if we are dealing with CRIO or containerd @@ -718,6 +722,7 @@ function main() { containerd_conf_file="${containerd_conf_tmpl_file}" containerd_conf_file_backup="${containerd_conf_tmpl_file}.bak" elif [[ "$runtime" =~ ^(k0s-worker|k0s-controller)$ ]]; then + mkdir -p $(dirname "$containerd_conf_file") touch "$containerd_conf_file" elif [[ "$runtime" == "containerd" ]]; then if [ ! -f "$containerd_conf_file" ] && [ -d $(dirname "$containerd_conf_file") ] && [ -x $(command -v containerd) ]; then