mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-03 01:44:29 +00:00
kata-deploy: configure multiple runtimes with containerd
Fixes: #504 Signed-off-by: Eric Ernst <eric.ernst@intel.com>
This commit is contained in:
@@ -13,9 +13,12 @@ crio_conf_file_backup="${crio_conf_file}.bak"
|
|||||||
containerd_conf_file="/etc/containerd/config.toml"
|
containerd_conf_file="/etc/containerd/config.toml"
|
||||||
containerd_conf_file_backup="${containerd_conf_file}.bak"
|
containerd_conf_file_backup="${containerd_conf_file}.bak"
|
||||||
|
|
||||||
shim_binary="containerd-shim-kata-v2"
|
shims=(
|
||||||
shim_file="/usr/local/bin/${shim_binary}"
|
"qemu"
|
||||||
shim_backup="/usr/local/bin/${shim_binary}.bak"
|
"nemu"
|
||||||
|
"fc"
|
||||||
|
)
|
||||||
|
|
||||||
# If we fail for any reason a message will be displayed
|
# If we fail for any reason a message will be displayed
|
||||||
die() {
|
die() {
|
||||||
msg="$*"
|
msg="$*"
|
||||||
@@ -131,29 +134,46 @@ function configure_containerd() {
|
|||||||
[plugins.cri.containerd]
|
[plugins.cri.containerd]
|
||||||
[plugins.cri.containerd.runtimes.kata]
|
[plugins.cri.containerd.runtimes.kata]
|
||||||
runtime_type = "io.containerd.kata.v2"
|
runtime_type = "io.containerd.kata.v2"
|
||||||
|
[plugins.cri.containerd.runtimes.kata.options]
|
||||||
|
ConfigPath = "/opt/kata/share/defaults/kata-containers/configuration.toml"
|
||||||
|
[plugins.cri.containerd.runtimes.kata-fc]
|
||||||
|
runtime_type = "io.containerd.kata-fc.v2"
|
||||||
|
[plugins.cri.containerd.runtimes.kata-fc.options]
|
||||||
|
ConfigPath = "/opt/kata/share/defaults/kata-containers/configuration-fc.toml"
|
||||||
|
[plugins.cri.containerd.runtimes.kata-qemu]
|
||||||
|
runtime_type = "io.containerd.kata-qemu.v2"
|
||||||
|
[plugins.cri.containerd.runtimes.kata-qemu.options]
|
||||||
|
ConfigPath = "/opt/kata/share/defaults/kata-containers/configuration-qemu.toml"
|
||||||
|
[plugins.cri.containerd.runtimes.kata-nemu]
|
||||||
|
runtime_type = "io.containerd.kata-nemu.v2"
|
||||||
|
[plugins.cri.containerd.runtimes.kata-nemu.options]
|
||||||
|
ConfigPath = "/opt/kata/share/defaults/kata-containers/configuration-nemu.toml"
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
|
|
||||||
#Currently containerd has an assumption on the location of the shimv2 implementation
|
#Currently containerd has an assumption on the location of the shimv2 implementation
|
||||||
#Until support is added (see https://github.com/containerd/containerd/issues/3073),
|
#Until support is added (see https://github.com/containerd/containerd/issues/3073),
|
||||||
#create a link in /usr/local/bin/ to the v2-shim implementation in /opt/kata/bin.
|
#create a link in /usr/local/bin/ to the v2-shim implementation in /opt/kata/bin.
|
||||||
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
|
|
||||||
|
|
||||||
mkdir -p /usr/local/bin
|
mkdir -p /usr/local/bin
|
||||||
|
|
||||||
cat << EOT | tee "$shim_file"
|
for shim in ${shims[@]}; do
|
||||||
#!/bin/bash
|
local shim_binary="containerd-shim-kata-${shim}-v2"
|
||||||
KATA_CONF_FILE=/opt/kata/share/defaults/kata-containers/configuration.toml /opt/kata/bin/${shim_binary} \$@
|
local shim_file="/usr/local/bin/${shim_binary}"
|
||||||
EOT
|
local shim_backup="/usr/local/bin/${shim_binary}.bak"
|
||||||
chmod +x $shim_file
|
|
||||||
|
|
||||||
|
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 remove_artifacts() {
|
function remove_artifacts() {
|
||||||
@@ -186,10 +206,19 @@ function cleanup_containerd() {
|
|||||||
|
|
||||||
#Currently containerd has an assumption on the location of the shimv2 implementation
|
#Currently containerd has an assumption on the location of the shimv2 implementation
|
||||||
#Until support is added (see https://github.com/containerd/containerd/issues/3073), we manage
|
#Until support is added (see https://github.com/containerd/containerd/issues/3073), we manage
|
||||||
# a symlink to the v2-shim implementation
|
# a reference to the v2-shim implementation
|
||||||
if [ -f "$shim_backup" ]; then
|
|
||||||
mv "$shim_backup" "$shim_file"
|
for shim in ${shims[@]}; do
|
||||||
fi
|
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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user