mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 02:56:18 +00:00
utils: kata-manager: Allow installing kata from a given tarball
With this change, we give the users the change to try kata-containers with their own pre-built tarball. This will become very useful in the CI context, as we won't be downloading a specific version of kata-containers, but rather installing whatever was built in previous steps of the CI pipeline. Fixes: #8438 Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
parent
fd9b6d6837
commit
38d2edd83b
@ -264,6 +264,7 @@ Options:
|
|||||||
-f : Force installation (use with care).
|
-f : Force installation (use with care).
|
||||||
-h : Show this help statement.
|
-h : Show this help statement.
|
||||||
-k <version> : Specify Kata Containers version.
|
-k <version> : Specify Kata Containers version.
|
||||||
|
-K <tarball> : Specify local Kata Containers tarball to install (takes priority over '-k').
|
||||||
-l : List installed and available versions only, then exit (uses network).
|
-l : List installed and available versions only, then exit (uses network).
|
||||||
-o : Only install Kata Containers.
|
-o : Only install Kata Containers.
|
||||||
-r : Don't cleanup on failure (retain files).
|
-r : Don't cleanup on failure (retain files).
|
||||||
@ -583,9 +584,13 @@ configure_containerd()
|
|||||||
install_kata()
|
install_kata()
|
||||||
{
|
{
|
||||||
local requested_version="${1:-}"
|
local requested_version="${1:-}"
|
||||||
|
local kata_tarball="${2:-}"
|
||||||
|
|
||||||
local project="$kata_project"
|
local project="$kata_project"
|
||||||
|
|
||||||
|
local version=""
|
||||||
|
if [ -z "$kata_tarball" ]
|
||||||
|
then
|
||||||
local version_desc="latest version"
|
local version_desc="latest version"
|
||||||
[ -n "$requested_version" ] && version_desc="version $requested_version"
|
[ -n "$requested_version" ] && version_desc="version $requested_version"
|
||||||
|
|
||||||
@ -599,13 +604,16 @@ install_kata()
|
|||||||
|
|
||||||
[ -z "$results" ] && die "Cannot download $project release file"
|
[ -z "$results" ] && die "Cannot download $project release file"
|
||||||
|
|
||||||
local version
|
|
||||||
version=$(echo "$results"|cut -d: -f1)
|
version=$(echo "$results"|cut -d: -f1)
|
||||||
|
|
||||||
|
[ -z "$version" ] && die "Cannot determine $project resolved version"
|
||||||
|
|
||||||
local file
|
local file
|
||||||
file=$(echo "$results"|cut -d: -f2-)
|
file=$(echo "$results"|cut -d: -f2-)
|
||||||
|
else
|
||||||
|
file="$kata_tarball"
|
||||||
|
fi
|
||||||
|
|
||||||
[ -z "$version" ] && die "Cannot determine $project resolved version"
|
|
||||||
[ -z "$file" ] && die "Cannot determine $project release file"
|
[ -z "$file" ] && die "Cannot determine $project release file"
|
||||||
|
|
||||||
# Allow the containerd service to find the Kata shim and users to find
|
# Allow the containerd service to find the Kata shim and users to find
|
||||||
@ -627,7 +635,12 @@ install_kata()
|
|||||||
|
|
||||||
[ -n "$unexpected" ] && die "File '$file' contains unexpected paths: '$unexpected'"
|
[ -n "$unexpected" ] && die "File '$file' contains unexpected paths: '$unexpected'"
|
||||||
|
|
||||||
|
if [ -n "$kata_tarball" ]
|
||||||
|
then
|
||||||
|
info "Installing $project release from $file"
|
||||||
|
else
|
||||||
info "Installing $project release $version from $file"
|
info "Installing $project release $version from $file"
|
||||||
|
fi
|
||||||
|
|
||||||
sudo tar -C / -xvf "${file}"
|
sudo tar -C / -xvf "${file}"
|
||||||
|
|
||||||
@ -680,11 +693,12 @@ configure_kata()
|
|||||||
handle_kata()
|
handle_kata()
|
||||||
{
|
{
|
||||||
local version="${1:-}"
|
local version="${1:-}"
|
||||||
|
local tarball="${2:-}"
|
||||||
|
|
||||||
local enable_debug="${2:-}"
|
local enable_debug="${3:-}"
|
||||||
[ -z "$enable_debug" ] && die "no enable debug value"
|
[ -z "$enable_debug" ] && die "no enable debug value"
|
||||||
|
|
||||||
install_kata "$version" "$enable_debug"
|
install_kata "$version" "$tarball" "$enable_debug"
|
||||||
|
|
||||||
configure_kata "$enable_debug"
|
configure_kata "$enable_debug"
|
||||||
|
|
||||||
@ -838,10 +852,10 @@ handle_installation()
|
|||||||
# These params can be blank
|
# These params can be blank
|
||||||
local kata_version="${7:-}"
|
local kata_version="${7:-}"
|
||||||
local containerd_flavour="${8:-}"
|
local containerd_flavour="${8:-}"
|
||||||
|
|
||||||
local install_docker="${9:-}"
|
local install_docker="${9:-}"
|
||||||
[ -z "$install_docker" ] && die "no install docker value"
|
[ -z "$install_docker" ] && die "no install docker value"
|
||||||
|
|
||||||
|
local kata_tarball="${10:-}"
|
||||||
# The tool to be testing the installation with
|
# The tool to be testing the installation with
|
||||||
local tool="ctr"
|
local tool="ctr"
|
||||||
|
|
||||||
@ -861,7 +875,7 @@ handle_installation()
|
|||||||
|
|
||||||
setup "$cleanup" "$force" "$skip_containerd"
|
setup "$cleanup" "$force" "$skip_containerd"
|
||||||
|
|
||||||
handle_kata "$kata_version" "$enable_debug"
|
handle_kata "$kata_version" "$kata_tarball" "$enable_debug"
|
||||||
|
|
||||||
[ "$skip_containerd" = "false" ] && \
|
[ "$skip_containerd" = "false" ] && \
|
||||||
handle_containerd \
|
handle_containerd \
|
||||||
@ -957,8 +971,9 @@ handle_args()
|
|||||||
|
|
||||||
local kata_version=""
|
local kata_version=""
|
||||||
local containerd_flavour="lts"
|
local containerd_flavour="lts"
|
||||||
|
local kata_tarball=""
|
||||||
|
|
||||||
while getopts "c:dDfhk:lortT" opt "$@"
|
while getopts "c:dDfhk:K:lortT" opt "$@"
|
||||||
do
|
do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
c) containerd_flavour="$OPTARG" ;;
|
c) containerd_flavour="$OPTARG" ;;
|
||||||
@ -967,6 +982,7 @@ handle_args()
|
|||||||
f) force="true" ;;
|
f) force="true" ;;
|
||||||
h) usage; exit 0 ;;
|
h) usage; exit 0 ;;
|
||||||
k) kata_version="$OPTARG" ;;
|
k) kata_version="$OPTARG" ;;
|
||||||
|
K) kata_tarball="$OPTARG" ;;
|
||||||
l) list_versions='true' ;;
|
l) list_versions='true' ;;
|
||||||
o) skip_containerd="true" ;;
|
o) skip_containerd="true" ;;
|
||||||
r) cleanup="false" ;;
|
r) cleanup="false" ;;
|
||||||
@ -995,7 +1011,8 @@ handle_args()
|
|||||||
"$only_run_test" \
|
"$only_run_test" \
|
||||||
"$kata_version" \
|
"$kata_version" \
|
||||||
"$containerd_flavour" \
|
"$containerd_flavour" \
|
||||||
"$install_docker"
|
"$install_docker" \
|
||||||
|
"$kata_tarball"
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user