118 lines
3.5 KiB
Bash
118 lines
3.5 KiB
Bash
#!/bin/bash
|
|
|
|
# Dependencies:
|
|
#
|
|
# - functions
|
|
|
|
# stack.sh
|
|
# ---------
|
|
# - check_crio
|
|
# - install_crio
|
|
# - configure_crio
|
|
# - stop_crio
|
|
|
|
# Save trace setting
|
|
_XTRACE_DOCKER=$(set +o | grep xtrace)
|
|
set +o xtrace
|
|
|
|
|
|
# Defaults
|
|
# --------
|
|
|
|
CRIO_ENGINE_SOCKET_FILE=${CRIO_ENGINE_SOCKET_FILE:-/var/run/crio/crio.sock}
|
|
|
|
# Functions
|
|
# ---------
|
|
|
|
function check_crio {
|
|
if is_ubuntu; then
|
|
dpkg -l | grep crio-o > /dev/null 2>&1
|
|
else
|
|
false
|
|
# TODO: CentOS/Fedora support.
|
|
fi
|
|
}
|
|
|
|
function install_crio {
|
|
if [[ -z "$os_PACKAGE" ]]; then
|
|
GetOSVersion
|
|
fi
|
|
|
|
local lsb_dist=${os_VENDOR,,}
|
|
local dist_version=${os_CODENAME}
|
|
local kubic_obs_project_key="2472d6d0d2f66af87aba8da34d64390375060aa4"
|
|
local os="x${os_VENDOR}_${os_RELEASE}"
|
|
if is_ubuntu; then
|
|
apt_get install apt-transport-https ca-certificates \
|
|
software-properties-common
|
|
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 \
|
|
--recv ${kubic_obs_project_key}
|
|
sudo apt-add-repository "deb https://download.opensuse.org/"`
|
|
`"repositories/devel:/kubic:/libcontainers:/stable/${os}/ /"
|
|
sudo apt-add-repository "deb http://download.opensuse.org/"`
|
|
`"repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/"`
|
|
`"${CRIO_VERSION}/${os}/ /"
|
|
|
|
# Installing podman and containerd will get us compatible versions of
|
|
# cri-o and runc. And we need podman to manage container images anyway.
|
|
apt_get install podman buildah cri-o-runc cri-o
|
|
elif is_fedora; then
|
|
if [[ "$lsb_dist" = "centos" ]]; then
|
|
sudo yum-config-manager \
|
|
--add-repo \
|
|
https://cbs.centos.org/repos/virt7-container-common-candidate/x86_64/os/
|
|
sudo yum-config-manager \
|
|
--add-repo \
|
|
https://cbs.centos.org/repos/paas7-crio-311-candidate/x86_64/os/
|
|
fi
|
|
yum_install cri-o podman buildah
|
|
fi
|
|
}
|
|
|
|
function configure_crio {
|
|
# After an ./unstack it will be stopped. So it is ok if it returns exit-code == 1
|
|
sudo systemctl stop crio.service || true
|
|
|
|
local crio_conf
|
|
crio_conf=/etc/crio/crio.conf
|
|
|
|
# We're wrapping values in \"<val>\" because that's the format cri-o wants.
|
|
iniset -sudo ${crio_conf} crio.api listen \"${CRIO_ENGINE_SOCKET_FILE}\"
|
|
if [[ "$ENABLE_DEBUG_LOG_LEVEL" == "True" ]]; then
|
|
# debug is way too verbose, info will be enough
|
|
iniset -sudo ${crio_conf} crio.runtime log_level \"info\"
|
|
fi
|
|
if is_ubuntu; then
|
|
# At least for 18.04 we need to set up /etc/containers/registries.conf
|
|
# with some initial content. That's another bug with that PPA.
|
|
local registries_conf
|
|
registries_conf="/etc/containers/registries.conf"
|
|
if [[ ! -f ${registries_conf} ]]; then
|
|
sudo mkdir -p `dirname ${registries_conf}`
|
|
cat << EOF | sudo tee ${registries_conf}
|
|
[registries.search]
|
|
registries = ['docker.io']
|
|
EOF
|
|
fi
|
|
elif is_fedora; then
|
|
local lsb_dist=${os_VENDOR,,}
|
|
|
|
if [[ "$lsb_dist" = "centos" ]]; then
|
|
# CentOS packages are putting runc binary in different place...
|
|
iniset -sudo ${crio_conf} crio.runtime runtime \"/usr/sbin/runc\"
|
|
|
|
# CentOS version seems to only work with cgroupfs...
|
|
iniset -sudo ${crio_conf} crio.runtime cgroup_manager \"cgroupfs\"
|
|
fi
|
|
fi
|
|
|
|
sudo systemctl --no-block restart crio.service
|
|
}
|
|
|
|
function stop_crio {
|
|
sudo systemctl stop crio.service || true
|
|
}
|
|
|
|
# Restore xtrace
|
|
$_XTRACE_DOCKER
|