Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
541d79af77 | ||
|
|
cdb06f60eb | ||
| 9690a7709b | |||
|
|
f896c23116 | ||
|
|
b8ff250e97 | ||
|
|
7e44a59c1e | ||
|
|
63c7b8eddc | ||
|
|
17a865e064 | ||
|
|
6d65af2900 | ||
|
|
34f6e6fd42 |
@@ -2,4 +2,4 @@
|
||||
host=review.opendev.org
|
||||
port=29418
|
||||
project=openstack/devstack-plugin-container.git
|
||||
defaultbranch=stable/rocky
|
||||
defaultbranch=stable/stein
|
||||
|
||||
118
devstack/lib/crio
Normal file
118
devstack/lib/crio
Normal file
@@ -0,0 +1,118 @@
|
||||
#!/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 arch=$(dpkg --print-architecture)
|
||||
if is_ubuntu; then
|
||||
apt_get install apt-transport-https ca-certificates software-properties-common
|
||||
sudo add-apt-repository -y ppa:projectatomic/ppa
|
||||
# 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
|
||||
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
|
||||
# In Ubuntu's a special vendored version of runc is installed with
|
||||
# cri-o. This means that it'll not work with the system's version of
|
||||
# runc. Moreover vendored runc is not placed into /usr/bin, where
|
||||
# crio.conf states that it will be. We fix that by linking the vendored
|
||||
# binary to /usr/bin.
|
||||
if [[ ! -e /usr/bin/runc ]]; then
|
||||
sudo ln -s /usr/lib/cri-o-runc/sbin/runc /usr/bin/runc
|
||||
sudo chmod +x /usr/bin/runc
|
||||
fi
|
||||
|
||||
# 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
|
||||
@@ -28,6 +28,7 @@ DOCKER_GROUP=${DOCKER_GROUP:-$STACK_USER}
|
||||
DOCKER_CGROUP_DRIVER=${DOCKER_CGROUP_DRIVER:-}
|
||||
ENABLE_CLEAR_CONTAINER=$(trueorfalse False ENABLE_CLEAR_CONTAINER)
|
||||
ENABLE_LIVE_RESTORE=$(trueorfalse False ENABLE_LIVE_RESTORE)
|
||||
ENABLE_IPV6=$(trueorfalse False ENABLE_IPV6)
|
||||
|
||||
# Functions
|
||||
# ---------
|
||||
@@ -112,6 +113,7 @@ function configure_docker {
|
||||
local docker_config_file=/etc/docker/daemon.json
|
||||
local debug
|
||||
local live_restore
|
||||
local ipv6
|
||||
if [[ "$ENABLE_DEBUG_LOG_LEVEL" == "True" ]]; then
|
||||
debug=true
|
||||
else
|
||||
@@ -122,6 +124,11 @@ function configure_docker {
|
||||
else
|
||||
live_restore=false
|
||||
fi
|
||||
if [[ "$ENABLE_IPV6" == "True" ]]; then
|
||||
ipv6=true
|
||||
else
|
||||
ipv6=false
|
||||
fi
|
||||
sudo mkdir -p $(dirname ${docker_config_file})
|
||||
cat <<EOF | sudo tee $docker_config_file >/dev/null
|
||||
{
|
||||
@@ -129,6 +136,7 @@ function configure_docker {
|
||||
$runtime_opts
|
||||
"debug": ${debug},
|
||||
"live-restore": ${live_restore},
|
||||
"ipv6": ${ipv6},
|
||||
"group": "$DOCKER_GROUP",
|
||||
EOF
|
||||
if [[ -n "$DOCKER_CGROUP_DRIVER" ]]; then
|
||||
|
||||
@@ -6,6 +6,7 @@ set -o xtrace
|
||||
|
||||
echo_summary "container's plugin.sh was called..."
|
||||
source $DEST/devstack-plugin-container/devstack/lib/docker
|
||||
source $DEST/devstack-plugin-container/devstack/lib/crio
|
||||
(set -o posix; set)
|
||||
|
||||
if is_service_enabled container; then
|
||||
@@ -13,17 +14,23 @@ if is_service_enabled container; then
|
||||
echo_summary "Installing container engine"
|
||||
if [[ ${CONTAINER_ENGINE} == "docker" ]]; then
|
||||
check_docker || install_docker
|
||||
elif [[ ${CONTAINER_ENGINE} == "crio" ]]; then
|
||||
check_crio || install_crio
|
||||
fi
|
||||
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||
echo_summary "Configuring container engine"
|
||||
if [[ ${CONTAINER_ENGINE} == "docker" ]]; then
|
||||
configure_docker
|
||||
elif [[ ${CONTAINER_ENGINE} == "crio" ]]; then
|
||||
configure_crio
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
if [[ ${CONTAINER_ENGINE} == "docker" ]]; then
|
||||
stop_docker
|
||||
elif [[ ${CONTAINER_ENGINE} == "crio" ]]; then
|
||||
stop_crio
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# Devstack settings
|
||||
|
||||
# Supported options are "docker" and "crio".
|
||||
CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker}
|
||||
ENABLE_CLEAR_CONTAINER=${ENABLE_CLEAR_CONTAINER:-false}
|
||||
ENABLE_LIVE_RESTORE=${ENABLE_LIVE_RESTORE:-false}
|
||||
ENABLE_IPV6=${ENABLE_IPV6:-false}
|
||||
|
||||
# Enable container services
|
||||
enable_service container
|
||||
|
||||
Reference in New Issue
Block a user