Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
Enable CRI-O container runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
electrocucaracha committed Apr 17, 2019
1 parent a8f57fc commit 10bcd1a
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
vagrant/.vagrant
vagrant/inventory/artifacts/
vagrant/inventory/group_vars/all.yml
vagrant/inventory/group_vars/*_container-manager.yml
vagrant/roles
qat*.tar.gz
*.retry
Expand Down
6 changes: 4 additions & 2 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ if ENV['no_proxy'] != nil or ENV['NO_PROXY']
end
end

container_runtime = (ENV['QAT_CONTAINER_RUNTIME'] || :docker).to_sym
distro = (ENV['QAT_DISTRO'] || :centos).to_sym
vagrant_root = File.dirname(__FILE__)
vagrant_root.slice! "vagrant"
puts "[INFO] Shared folder: #{vagrant_root}"
puts "[INFO] Linux Distro: #{distro} "
puts "[INFO] Linux Distro: #{distro}"
puts "[INFO] Runtime container: #{container_runtime}"

Vagrant.configure("2") do |config|
config.vm.provider :libvirt
Expand All @@ -53,7 +55,7 @@ Vagrant.configure("2") do |config|
config.vm.provision :reload
config.vm.provision 'shell', privileged: false do |sh|
sh.env = {
'JENKINS_HOME': '/home/vagrant'
'CONTAINER_MANAGER': "#{container_runtime}"
}
sh.inline = <<-SHELL
cd #{vagrant_root}
Expand Down
74 changes: 65 additions & 9 deletions vagrant/_commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,42 @@ function uninstall_k8s {
ansible-playbook -vvv -i ./inventory/hosts.ini $kubespray_folder/reset.yml --become
}

# _install_docker() - Download and install docker-engine
function _install_docker {
if docker version &>/dev/null; then
return
fi

source /etc/os-release || source /usr/lib/os-release
case ${ID,,} in
clear-linux-os)
sudo -E swupd bundle-add containers-basic
sudo systemctl unmask docker.service
;;
*)
curl -fsSL https://get.docker.com/ | sh
;;
esac

sudo mkdir -p /etc/systemd/system/docker.service.d
if [ -n "$HTTP_PROXY" ]; then
echo "[Service]" | sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf
echo "Environment=\"HTTP_PROXY=$HTTP_PROXY\"" | sudo tee --append /etc/systemd/system/docker.service.d/http-proxy.conf
fi
if [ -n "$HTTPS_PROXY" ]; then
echo "[Service]" | sudo tee /etc/systemd/system/docker.service.d/https-proxy.conf
echo "Environment=\"HTTPS_PROXY=$HTTPS_PROXY\"" | sudo tee --append /etc/systemd/system/docker.service.d/https-proxy.conf
fi
if [ -n "$NO_PROXY" ]; then
echo "[Service]" | sudo tee /etc/systemd/system/docker.service.d/no-proxy.conf
echo "Environment=\"NO_PROXY=$NO_PROXY\"" | sudo tee --append /etc/systemd/system/docker.service.d/no-proxy.conf
fi
sudo usermod -aG docker "$USER"
sudo systemctl daemon-reload
sudo systemctl restart docker
sleep 10
}

# install_k8s() - Install Kubernetes using kubespray tool
function install_k8s {
echo "Deploying kubernetes"
Expand All @@ -34,23 +70,43 @@ function install_k8s {
sudo yum install -y git
;;
clear-linux-os)
sudo systemctl unmask docker.service
sudo swupd bundle-add git
;;
esac
#sudo git clone https://github.com/kubernetes-sigs/kubespray $kubespray_folder
sudo git clone https://github.com/electrocucaracha/kubespray $kubespray_folder
sudo chown -R "$USER" $kubespray_folder
pushd $kubespray_folder
#git checkout release-2.9
pushd $kubespray_folder || exit
git checkout fix_runc_path
sudo -E pip install -r requirements.txt
popd
popd || exit

echo "Kubespray configuration"

rm -f ./inventory/group_vars/all.yml 2> /dev/null
echo "kubeadm_enabled: true" | tee ./inventory/group_vars/all.yml
rm -f ./inventory/group_vars/*_container-manager.yml 2> /dev/null
echo "kubeadm_enabled: true" > ./inventory/group_vars/all.yml
if [[ "$CONTAINER_MANAGER" == "crio" ]]; then
echo "CRI-O configuration"
{
echo "download_container: false"
echo "skip_downloads: false"
} >> ./inventory/group_vars/all.yml
cp crio_container-manager.yml ./inventory/group_vars/
_install_docker
sudo mkdir -p /etc/systemd/system/crio.service.d/
if [ -n "$HTTP_PROXY" ]; then
echo "[Service]" | sudo tee /etc/systemd/system/crio.service.d/http-proxy.conf
echo "Environment=\"HTTP_PROXY=$HTTP_PROXY\"" | sudo tee --append /etc/systemd/system/crio.service.d/http-proxy.conf
fi
if [ -n "$HTTPS_PROXY" ]; then
echo "[Service]" | sudo tee /etc/systemd/system/crio.service.d/https-proxy.conf
echo "Environment=\"HTTPS_PROXY=$HTTPS_PROXY\"" | sudo tee --append /etc/systemd/system/crio.service.d/https-proxy.conf
fi
if [ -n "$NO_PROXY" ]; then
echo "[Service]" | sudo tee /etc/systemd/system/crio.service.d/no-proxy.conf
echo "Environment=\"NO_PROXY=$NO_PROXY\"" | sudo tee --append /etc/systemd/system/crio.service.d/no-proxy.conf
fi
fi
if [[ ${HTTP_PROXY+x} = "x" ]]; then
echo "http_proxy: \"$HTTP_PROXY\"" | tee --append ./inventory/group_vars/all.yml
echo "http_proxy: \"$HTTP_PROXY\"" | tee --append ./inventory/group_vars/all.yml
fi
if [[ ${HTTPS_PROXY+x} = "x" ]]; then
echo "https_proxy: \"$HTTPS_PROXY\"" | tee --append ./inventory/group_vars/all.yml
Expand Down
13 changes: 13 additions & 0 deletions vagrant/crio_container-manager.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2019 Intel Corporation
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

# Enable CRI-O lightweight container runtime
etcd_deployment_type: host
kubelet_deployment_type: host
container_manager: crio

0 comments on commit 10bcd1a

Please sign in to comment.