mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-01 07:47:15 +00:00
Merge pull request #10194 from fidencio/topic/kata-deploy-re-work-logic
kata-deploy: Rework the logic a little bit
This commit is contained in:
commit
2f6edc4b9b
@ -13,6 +13,7 @@ crio_drop_in_conf_file="${crio_drop_in_conf_dir}/99-kata-deploy"
|
|||||||
crio_drop_in_conf_file_debug="${crio_drop_in_conf_dir}/100-debug"
|
crio_drop_in_conf_file_debug="${crio_drop_in_conf_dir}/100-debug"
|
||||||
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"
|
||||||
|
containerd_conf_tmpl_file=""
|
||||||
|
|
||||||
IFS=' ' read -a shims <<< "$SHIMS"
|
IFS=' ' read -a shims <<< "$SHIMS"
|
||||||
default_shim="$DEFAULT_SHIM"
|
default_shim="$DEFAULT_SHIM"
|
||||||
@ -574,6 +575,15 @@ function snapshotter_handler_mapping_validation_check() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
action=${1:-}
|
||||||
|
if [ -z "$action" ]; then
|
||||||
|
print_usage
|
||||||
|
die "invalid arguments"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Action:"
|
||||||
|
echo "* $action"
|
||||||
|
echo ""
|
||||||
echo "Environment variables passed to this script"
|
echo "Environment variables passed to this script"
|
||||||
echo "* NODE_NAME: ${NODE_NAME}"
|
echo "* NODE_NAME: ${NODE_NAME}"
|
||||||
echo "* DEBUG: ${DEBUG}"
|
echo "* DEBUG: ${DEBUG}"
|
||||||
@ -598,32 +608,14 @@ function main() {
|
|||||||
# CRI-O isn't consistent with the naming -- let's use crio to match the service file
|
# CRI-O isn't consistent with the naming -- let's use crio to match the service file
|
||||||
if [ "$runtime" == "cri-o" ]; then
|
if [ "$runtime" == "cri-o" ]; then
|
||||||
runtime="crio"
|
runtime="crio"
|
||||||
elif [ "$runtime" == "k3s" ] || [ "$runtime" == "k3s-agent" ] || [ "$runtime" == "rke2-agent" ] || [ "$runtime" == "rke2-server" ]; then
|
elif [[ "$runtime" =~ ^(k3s|k3s-agent|rke2-agent|rke2-server)$ ]]; then
|
||||||
containerd_conf_tmpl_file="${containerd_conf_file}.tmpl"
|
containerd_conf_tmpl_file="${containerd_conf_file}.tmpl"
|
||||||
if [ ! -f "$containerd_conf_tmpl_file" ] && [ -f "$containerd_conf_file" ]; then
|
containerd_conf_file_backup="${containerd_conf_tmpl_file}.bak"
|
||||||
cp "$containerd_conf_file" "$containerd_conf_tmpl_file"
|
elif [[ "$runtime" =~ ^(k0s-worker|k0s-controller)$ ]]; then
|
||||||
fi
|
|
||||||
|
|
||||||
containerd_conf_file="${containerd_conf_tmpl_file}"
|
|
||||||
containerd_conf_file_backup="${containerd_conf_file}.bak"
|
|
||||||
elif [ "$runtime" == "k0s-worker" ] || [ "$runtime" == "k0s-controller" ]; then
|
|
||||||
# From 1.27.1 onwards k0s enables dynamic configuration on containerd CRI runtimes.
|
# 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.
|
# 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.
|
# 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/kata-containers.toml"
|
||||||
touch "$containerd_conf_file"
|
|
||||||
else
|
|
||||||
# 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
|
|
||||||
|
|
||||||
action=${1:-}
|
|
||||||
if [ -z "$action" ]; then
|
|
||||||
print_usage
|
|
||||||
die "invalid arguments"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only install / remove / update if we are dealing with CRIO or containerd
|
# only install / remove / update if we are dealing with CRIO or containerd
|
||||||
@ -635,11 +627,32 @@ function main() {
|
|||||||
|
|
||||||
case "$action" in
|
case "$action" in
|
||||||
install)
|
install)
|
||||||
|
if [[ "$runtime" =~ ^(k3s|k3s-agent|rke2-agent|rke2-server)$ ]]; then
|
||||||
|
if [ ! -f "$containerd_conf_tmpl_file" ] && [ -f "$containerd_conf_file" ]; then
|
||||||
|
cp "$containerd_conf_file" "$containerd_conf_tmpl_file"
|
||||||
|
fi
|
||||||
|
# Only set the containerd_conf_file to its new value after
|
||||||
|
# copying the file to the template location
|
||||||
|
containerd_conf_file="${containerd_conf_tmpl_file}"
|
||||||
|
containerd_conf_file_backup="${containerd_conf_tmpl_file}.bak"
|
||||||
|
elif [[ "$runtime" =~ ^(k0s-worker|k0s-controller)$ ]]; then
|
||||||
|
touch "$containerd_conf_file"
|
||||||
|
elif [[ "$runtime" == "containerd" ]]; then
|
||||||
|
if [ ! -f "$containerd_conf_file" ] && [ -d $(dirname "$containerd_conf_file") ] && [ -x $(command -v containerd) ]; then
|
||||||
|
containerd config default > "$containerd_conf_file"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
install_artifacts
|
install_artifacts
|
||||||
configure_cri_runtime "$runtime"
|
configure_cri_runtime "$runtime"
|
||||||
kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=true
|
kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=true
|
||||||
;;
|
;;
|
||||||
cleanup)
|
cleanup)
|
||||||
|
if [[ "$runtime" =~ ^(k3s|k3s-agent|rke2-agent|rke2-server)$ ]]; then
|
||||||
|
containerd_conf_file_backup="${containerd_conf_tmpl_file}.bak"
|
||||||
|
containerd_conf_file="${containerd_conf_tmpl_file}"
|
||||||
|
fi
|
||||||
|
|
||||||
cleanup_cri_runtime "$runtime"
|
cleanup_cri_runtime "$runtime"
|
||||||
kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=cleanup
|
kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=cleanup
|
||||||
remove_artifacts
|
remove_artifacts
|
||||||
|
Loading…
Reference in New Issue
Block a user