diff --git a/tools/packaging/kata-deploy/README.md b/tools/packaging/kata-deploy/README.md index 938d7f83a7..8f9edb0864 100644 --- a/tools/packaging/kata-deploy/README.md +++ b/tools/packaging/kata-deploy/README.md @@ -133,17 +133,14 @@ This image contains all the necessary artifacts for running Kata Containers, all from the [Kata Containers release page](https://github.com/kata-containers/runtime/releases). Host artifacts: +* `cloud-hypervisor`, `firecracker`, `qemu-system-x86_64`, `qemu-virtiofs-system-x86_64` and supporting binaries +* `containerd-shim-kata-v2` +* `kata-collect-data.sh` * `kata-runtime` -* `kata-fc` -* `kata-qemu` -* `kata-proxy` -* `kata-shim` -* `firecracker` -* `qemu-system-x86_64` and supporting binaries Virtual Machine artifacts: -* `kata-containers.img`: pulled from Kata GitHub releases page -* `vmlinuz.container`: pulled from Kata GitHub releases page +* `kata-containers.img` and `kata-containers-initrd.img`: pulled from Kata GitHub releases page +* `vmlinuz.container` and `vmlinuz-virtiofs.container`: pulled from Kata GitHub releases page ### DaemonSets and RBAC diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 727098c2da..9903495c93 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -54,6 +54,8 @@ function install_artifacts() { } function configure_cri_runtime() { + configure_different_shims_base + case $1 in crio) configure_crio @@ -66,6 +68,77 @@ function configure_cri_runtime() { systemctl restart "$1" } +function configure_different_shims_base() { + # Currently containerd has an assumption on the location of the shimv2 implementation + # This forces kata-deploy to create files in a well-defined location that's part of + # the PATH, pointing to the containerd-shim-kata-v2 binary in /opt/kata/bin + # Issues: + # https://github.com/containerd/containerd/issues/3073 + # https://github.com/containerd/containerd/issues/5006 + + mkdir -p /usr/local/bin + + for shim in "${shims[@]}"; do + local shim_binary="containerd-shim-kata-${shim}-v2" + local shim_file="/usr/local/bin/${shim_binary}" + local shim_backup="/usr/local/bin/${shim_binary}.bak" + + if [ -f "${shim_file}" ]; then + echo "warning: ${shim_binary} already exists" >&2 + if [ ! -f "${shim_backup}" ]; then + mv "${shim_file}" "${shim_backup}" + else + rm "${shim_file}" + fi + fi + + cat << EOT | tee "$shim_file" +#!/bin/bash +KATA_CONF_FILE=/opt/kata/share/defaults/kata-containers/configuration-${shim}.toml /opt/kata/bin/containerd-shim-kata-v2 "\$@" +EOT + chmod +x "$shim_file" + done +} + +function cleanup_different_shims_base() { + for shim in "${shims[@]}"; do + local shim_binary="containerd-shim-kata-${shim}-v2" + local shim_file="/usr/local/bin/${shim_binary}" + local shim_backup="/usr/local/bin/${shim_binary}.bak" + + rm "${shim_file}" || true + + if [ -f "${shim_backup}" ]; then + mv "$shim_backup" "$shim_file" + fi + done +} + +function configure_crio_runtime() { + local runtime="kata" + if [ -n "${1-}" ]; then + runtime+="-$1" + fi + + local kata_path="/usr/local/bin/containerd-shim-${runtime}-v2" + local kata_conf="crio.runtime.runtimes.${runtime}" + + if grep -qEe "^\[$kata_conf\]" $crio_conf_file; then + echo "Configuration exists $kata_conf, overwriting" + sed -i "/\[$kata_conf\]/\[$kata_conf-original\]/" $crio_conf_file + fi + + cat <