diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 178a33279c..e8555fe55b 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -105,6 +105,42 @@ function get_container_runtime() { fi } +function get_kata_containers_config_path() { + local shim="$1" + + # Directory holding pristine configuration files for the current default golang runtime. + local golang_config_path="/opt/kata/share/defaults/kata-containers/" + + # Directory holding pristine configuration files for the new rust runtime. + # + # These are put into a separate directory since: + # + # - In some cases, the rust runtime configuration syntax is + # slightly different to the golang runtime configuration files + # so some hypervisors need two different configuration files, + # one for reach runtime type (for example Cloud Hypervisor which + # uses 'clh' for the golang runtime and 'cloud-hypervisor' for + # the rust runtime. + # + # - Some hypervisors only currently work with the golang runtime. + # + # - Some hypervisors only work with the rust runtime (dragonball). + # + # See: https://github.com/kata-containers/kata-containers/issues/6020 + local rust_config_path="${golang_config_path}/runtime-rs" + + local config_path + + # Map the runtime shim name to the appropriate configuration + # file directory. + case "$shim" in + dragonball) config_path="$rust_config_path" ;; + *) config_path="$golang_config_path" ;; + esac + + echo "$config_path" +} + function install_artifacts() { echo "copying kata artifacts onto host" cp -au /opt/kata-artifacts/opt/kata/* /opt/kata/ @@ -112,8 +148,12 @@ function install_artifacts() { [ -d /opt/kata/runtime-rs/bin ] && \ chmod +x /opt/kata/runtime-rs/bin/* - config_path="/opt/kata/share/defaults/kata-containers/" + local config_path + for shim in "${shims[@]}"; do + config_path=$(get_kata_containers_config_path "${shim}") + mkdir -p "$config_path" + local kata_config_file="${config_path}/configuration-${shim}.toml" # Allow enabling debug for Kata Containers if [[ "${DEBUG}" == "true" ]]; then @@ -257,9 +297,11 @@ function configure_crio_runtime() { configuration+="-$1" fi + local config_path=$(get_kata_containers_config_path "${1}") + local kata_path="/usr/local/bin/containerd-shim-${runtime}-v2" local kata_conf="crio.runtime.runtimes.${runtime}" - local kata_config_path="/opt/kata/share/defaults/kata-containers/$configuration.toml" + local kata_config_path="${config_path}/${configuration}.toml" cat <