kata-deploy-cc: Simplify the script

As containerd is the only supported container engine, let's simplify the
script and, at the same time, make it clear that other container engines
are not supported yet.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2022-09-05 14:17:44 +02:00
parent 1f610ea5cc
commit f684d00d50

View File

@ -204,11 +204,7 @@ function remove_artifacts() {
function cleanup_cri_runtime() { function cleanup_cri_runtime() {
cleanup_different_shims_base cleanup_different_shims_base
case $1 in cleanup_containerd
containerd | k3s | k3s-agent | rke2-agent | rke2-server)
cleanup_containerd
;;
esac
} }
@ -223,9 +219,7 @@ function reset_runtime() {
kubectl label node "$NODE_NAME" katacontainers.io/kata-runtime- kubectl label node "$NODE_NAME" katacontainers.io/kata-runtime-
systemctl daemon-reload systemctl daemon-reload
systemctl restart "$1" systemctl restart "$1"
if [ "$1" == "containerd" ]; then systemctl restart kubelet
systemctl restart kubelet
fi
} }
function main() { function main() {
@ -236,21 +230,13 @@ function main() {
fi fi
runtime=$(get_container_runtime) runtime=$(get_container_runtime)
if [ "$runtime" != "containerd" ]; then
die "$runtime is not supported for now"
fi
if [ "$runtime" == "k3s" ] || [ "$runtime" == "k3s-agent" ] || [ "$runtime" == "rke2-agent" ] || [ "$runtime" == "rke2-server" ]; then if [ ! -f "$containerd_conf_file" ] && [ -d $(dirname "$containerd_conf_file") ] && \
containerd_conf_tmpl_file="${containerd_conf_file}.tmpl" [ -x $(command -v containerd) ]; then
if [ ! -f "$containerd_conf_tmpl_file" ]; then containerd config default > "$containerd_conf_file"
cp "$containerd_conf_file" "$containerd_conf_tmpl_file"
fi
containerd_conf_file="${containerd_conf_tmpl_file}"
containerd_conf_file_backup="${containerd_conf_file}.bak"
elif [ "$runtime" == "containerd" ]; then
# runtime == containerd
if [ ! -f "$containerd_conf_file" ] && [ -d $(dirname "$containerd_conf_file") ] && \
[ -x $(command -v containerd) ]; then
containerd config default > "$containerd_conf_file"
fi
fi fi
action=${1:-} action=${1:-}
@ -259,29 +245,25 @@ function main() {
die "invalid arguments" die "invalid arguments"
fi fi
# only install / remove / update if we are dealing with containerd case "$action" in
if [[ "$runtime" =~ ^(containerd|k3s|k3s-agent|rke2-agent|rke2-server)$ ]]; then install)
install_artifacts
case "$action" in configure_cri_runtime "$runtime"
install) kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=true
install_artifacts ;;
configure_cri_runtime "$runtime" cleanup)
kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=true cleanup_cri_runtime "$runtime"
;; kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=cleanup
cleanup) remove_artifacts
cleanup_cri_runtime "$runtime" ;;
kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=cleanup reset)
remove_artifacts reset_runtime $runtime
;; ;;
reset) *)
reset_runtime $runtime echo invalid arguments
;; print_usage
*) ;;
echo invalid arguments esac
print_usage
;;
esac
fi
#It is assumed this script will be called as a daemonset. As a result, do #It is assumed this script will be called as a daemonset. As a result, do
# not return, otherwise the daemon will restart and rexecute the script # not return, otherwise the daemon will restart and rexecute the script