Skip to content

Commit

Permalink
ci: Create a generic install_crio function
Browse files Browse the repository at this point in the history
This will serve us quite will in the upcoming tests addition, which will
also have to be executed using CRi-O.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
(cherry picked from commit de1eeee)
  • Loading branch information
fidencio committed Oct 6, 2023
1 parent 98e9434 commit 5017435
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 40 deletions.
46 changes: 46 additions & 0 deletions tests/common.bash
Expand Up @@ -469,6 +469,52 @@ function install_nydus_snapshotter() {
rm -f "${tarball_name}"
}

function _get_os_for_crio() {
source /etc/os-release

if [ "${NAME}" != "Ubuntu" ]; then
echo "Only Ubuntu is supported for now"
exit 2
fi

echo "x${NAME}_${VERSION_ID}"
}

# version: the CRI-O version to be installe
function install_crio() {
local version=${1}

os=$(_get_os_for_crio)

echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/${os}/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/${version}/${os}/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:${version}.list
curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:${version}/${os}/Release.key | sudo apt-key add -
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/${os}/Release.key | sudo apt-key add -
sudo apt update
sudo apt install -y cri-o cri-o-runc

# We need to set the default capabilities to ensure our tests will pass
# See: https://github.com/kata-containers/kata-containers/issues/8034
sudo mkdir -p /etc/crio/crio.conf.d/
cat <<EOF | sudo tee /etc/crio/crio.conf.d/00-default-capabilities
[crio.runtime]
default_capabilities = [
"CHOWN",
"DAC_OVERRIDE",
"FSETID",
"FOWNER",
"SETGID",
"SETUID",
"SETPCAP",
"NET_BIND_SERVICE",
"KILL",
"SYS_CHROOT",
]
EOF

sudo systemctl enable --now crio
}

# Convert architecture to the name used by golang
function arch_to_golang() {
local arch="$(uname -m)"
Expand Down
41 changes: 1 addition & 40 deletions tests/gha-run-k8s-common.sh
Expand Up @@ -197,17 +197,6 @@ function _get_k0s_kubernetes_version_for_crio() {
echo ${crio_version}
}

function _get_os_for_crio() {
source /etc/os-release

if [ "${NAME}" != "Ubuntu" ]; then
echo "Only Ubuntu is supported for now"
exit 2
fi

echo "x${NAME}_${VERSION_ID}"
}

function setup_crio() {
# Get the CRI-O version to be installed depending on the version of the
# "k8s distro" that we are using
Expand All @@ -217,35 +206,7 @@ function setup_crio() {

esac

os=$(_get_os_for_crio)

echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/${os}/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/${crio_version}/${os}/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:${crio_version}.list
curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:${crio_version}/${os}/Release.key | sudo apt-key add -
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/${os}/Release.key | sudo apt-key add -
sudo apt update
sudo apt install -y cri-o cri-o-runc

# We need to set the default capabilities to ensure our tests will pass
# See: https://github.com/kata-containers/kata-containers/issues/8034
sudo mkdir -p /etc/crio/crio.conf.d/
cat <<EOF | sudo tee /etc/crio/crio.conf.d/00-default-capabilities
[crio.runtime]
default_capabilities = [
"CHOWN",
"DAC_OVERRIDE",
"FSETID",
"FOWNER",
"SETGID",
"SETUID",
"SETPCAP",
"NET_BIND_SERVICE",
"KILL",
"SYS_CHROOT",
]
EOF

sudo systemctl enable --now crio
install_crio ${crio_version}
}

function deploy_k8s() {
Expand Down

0 comments on commit 5017435

Please sign in to comment.