diff --git a/.gitignore b/.gitignore index c4d1d01..3733fe7 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile index 127b41b..31423b3 100644 --- a/vagrant/Vagrantfile +++ b/vagrant/Vagrantfile @@ -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 @@ -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} diff --git a/vagrant/_commons.sh b/vagrant/_commons.sh index 875ba62..c98d1df 100755 --- a/vagrant/_commons.sh +++ b/vagrant/_commons.sh @@ -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" @@ -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 diff --git a/vagrant/crio_container-manager.yml b/vagrant/crio_container-manager.yml new file mode 100644 index 0000000..8331f5c --- /dev/null +++ b/vagrant/crio_container-manager.yml @@ -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