summaryrefslogtreecommitdiffstats
path: root/vagrant/installer.sh
diff options
context:
space:
mode:
authorVictor Morales <victor.morales@intel.com>2018-10-23 03:47:50 -0700
committerVictor Morales <victor.morales@intel.com>2018-11-15 03:31:29 -0800
commit1b76b8fada122365b9adf99cc305721cc114d30a (patch)
tree2a7197aab0cb20cf14e397d0fd7465a0c94574cf /vagrant/installer.sh
parentdaf3a00798ee77e469cd89cb16ade818c50968f9 (diff)
Change deployment approach
This change pretends to isolate the deployment script and make it consumable externally. Change-Id: I7b9859fcc55e03e706aa54d4bc632ed15b4313be Signed-off-by: Victor Morales <victor.morales@intel.com> Issue-ID: MULTICLOUD-408
Diffstat (limited to 'vagrant/installer.sh')
-rwxr-xr-xvagrant/installer.sh101
1 files changed, 30 insertions, 71 deletions
diff --git a/vagrant/installer.sh b/vagrant/installer.sh
index 5fdcaeb5..b621afaa 100755
--- a/vagrant/installer.sh
+++ b/vagrant/installer.sh
@@ -9,22 +9,8 @@
##############################################################################
set -o errexit
-set -o nounset
set -o pipefail
-# usage() - Prints the usage of the program
-function usage {
- cat <<EOF
-usage: $0 [-a addons] [-p] [-v] [-w dir ]
-Optional Argument:
- -a List of Kubernetes AddOns to be installed ( e.g. "ovn-kubernetes virtlet multus")
- -p Installation of ONAP MultiCloud Kubernetes plugin
- -v Enable verbosity
- -w Working directory
- -t Running healthchecks
-EOF
-}
-
# _install_go() - Install GoLang package
function _install_go {
version=$(grep "go_version" ${krd_playbooks}/krd-vars.yml | awk -F ': ' '{print $2}')
@@ -57,10 +43,6 @@ function _install_pip {
# _install_ansible() - Install and Configure Ansible program
function _install_ansible {
mkdir -p /etc/ansible/
- cat <<EOL > /etc/ansible/ansible.cfg
-[defaults]
-host_key_checking = false
-EOL
if $(ansible --version &>/dev/null); then
return
fi
@@ -76,7 +58,7 @@ function _install_docker {
return
fi
apt-get install -y software-properties-common linux-image-extra-$(uname -r) linux-image-extra-virtual apt-transport-https ca-certificates curl
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install -y docker-ce
@@ -101,7 +83,7 @@ Environment="NO_PROXY=$no_proxy"
EOL
fi
systemctl daemon-reload
- echo "DOCKER_OPTS=\"-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --max-concurrent-downloads $max_concurrent_downloads \"" >> /etc/default/docker
+ echo "DOCKER_OPTS=\"-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --max-concurrent-downloads $max_concurrent_downloads \"" | tee --append /etc/default/docker
usermod -aG docker $USER
systemctl restart docker
@@ -119,24 +101,23 @@ function install_k8s {
_install_ansible
wget https://github.com/kubernetes-incubator/kubespray/archive/$tarball
tar -C $dest_folder -xzf $tarball
+ mv $dest_folder/kubespray-$version/ansible.cfg /etc/ansible/ansible.cfg
rm $tarball
- pushd $dest_folder/kubespray-$version
- pip install -r requirements.txt
- rm -f $krd_inventory_folder/group_vars/all.yml 2> /dev/null
- if [[ -n "${verbose+x}" ]]; then
- echo "kube_log_level: 5" >> $krd_inventory_folder/group_vars/all.yml
- else
- echo "kube_log_level: 2" >> $krd_inventory_folder/group_vars/all.yml
- fi
- if [[ -n "${http_proxy+x}" ]]; then
- echo "http_proxy: \"$http_proxy\"" >> $krd_inventory_folder/group_vars/all.yml
- fi
- if [[ -n "${https_proxy+x}" ]]; then
- echo "https_proxy: \"$https_proxy\"" >> $krd_inventory_folder/group_vars/all.yml
- fi
- ansible-playbook $verbose -i $krd_inventory cluster.yml -b | tee $log_folder/setup-kubernetes.log
- popd
+ pip install -r $dest_folder/kubespray-$version/requirements.txt
+ rm -f $krd_inventory_folder/group_vars/all.yml 2> /dev/null
+ if [[ -n "${verbose}" ]]; then
+ echo "kube_log_level: 5" | tee $krd_inventory_folder/group_vars/all.yml
+ else
+ echo "kube_log_level: 2" | tee $krd_inventory_folder/group_vars/all.yml
+ fi
+ if [[ -n "${http_proxy}" ]]; then
+ echo "http_proxy: \"$http_proxy\"" | tee --append $krd_inventory_folder/group_vars/all.yml
+ fi
+ if [[ -n "${https_proxy}" ]]; then
+ echo "https_proxy: \"$https_proxy\"" | tee --append $krd_inventory_folder/group_vars/all.yml
+ fi
+ ansible-playbook $verbose -i $krd_inventory $dest_folder/kubespray-$version/cluster.yml -b | tee $log_folder/setup-kubernetes.log
# Configure environment
mkdir -p $HOME/.kube
@@ -146,15 +127,14 @@ function install_k8s {
# install_addons() - Install Kubenertes AddOns
function install_addons {
echo "Installing Kubernetes AddOns"
- apt-get install -y sshpass
_install_ansible
- ansible-galaxy install -r $krd_folder/galaxy-requirements.yml --ignore-errors
+ ansible-galaxy install $verbose -r $krd_folder/galaxy-requirements.yml --ignore-errors
ansible-playbook $verbose -i $krd_inventory $krd_playbooks/configure-krd.yml | tee $log_folder/setup-krd.log
- for addon in $addons; do
+ for addon in ${KRD_ADDONS:-virtlet ovn-kubernetes multus}; do
echo "Deploying $addon using configure-$addon.yml playbook.."
ansible-playbook $verbose -i $krd_inventory $krd_playbooks/configure-${addon}.yml | tee $log_folder/setup-${addon}.log
- if [[ -n "${testing_enabled+x}" ]]; then
+ if [[ "${testing_enabled}" == "true" ]]; then
pushd $krd_tests
bash ${addon}.sh
popd
@@ -178,7 +158,7 @@ function install_plugin {
pushd $GOPATH/src/k8-plugin-multicloud/deployments
./build.sh
- if [[ -n "${testing_enabled+x}" ]]; then
+ if [[ "${testing_enabled}" = "true" ]]; then
docker-compose up -d
pushd $krd_tests
for functional_test in plugin plugin_edgex; do
@@ -207,46 +187,25 @@ function _print_kubernetes_info {
echo "Admin password: secret" >> $k8s_info_file
}
-# Configuration values
-addons="virtlet ovn-kubernetes multus"
-krd_folder="$(dirname "$0")"
-verbose=""
+if [[ -n "${KRD_DEBUG}" ]]; then
+ set -o xtrace
+ verbose="-vvv"
+fi
-while getopts "a:pvw:t" opt; do
- case $opt in
- a)
- addons="$OPTARG"
- ;;
- p)
- plugin_enabled="true"
- ;;
- v)
- set -o xtrace
- verbose="-vvv"
- ;;
- w)
- krd_folder="$OPTARG"
- ;;
- t)
- testing_enabled="true"
- ;;
- ?)
- usage
- exit
- ;;
- esac
-done
+# Configuration values
log_folder=/var/log/krd
+krd_folder=$(pwd)
krd_inventory_folder=$krd_folder/inventory
krd_inventory=$krd_inventory_folder/hosts.ini
krd_playbooks=$krd_folder/playbooks
krd_tests=$krd_folder/tests
k8s_info_file=$krd_folder/k8s_info.log
+testing_enabled=${KRD_ENABLE_TESTS:-true}
mkdir -p $log_folder
mkdir -p /opt/csar
export CSAR_DIR=/opt/csar
-echo "export CSAR_DIR=${CSAR_DIR}" >> /etc/environment
+echo "export CSAR_DIR=${CSAR_DIR}" | tee --append /etc/environment
# Install dependencies
# Setup proxy variables
@@ -257,7 +216,7 @@ fi
apt-get update
install_k8s
install_addons
-if [[ -n "${plugin_enabled+x}" ]]; then
+if [[ "${KRD_PLUGIN_ENABLED:-true}" ]]; then
install_plugin
fi
_print_kubernetes_info