Update documentation for Cluster-API and Flux
[icn.git] / deploy / kud / kud_bm_launch.sh
index 60784c4..b7dc9b8 100755 (executable)
@@ -1,19 +1,17 @@
-#!/bin/bash
-set +x
+#!/usr/bin/env bash
+set -eu -o pipefail
 
 LIBDIR="$(dirname "$(dirname "$PWD")")"
 
 source $LIBDIR/env/lib/common.sh
 
+export KUBESPRAY_VERSION=2.16.0
+
 function get_kud_repo {
-    if [ -d $DOWNLOAD_PATH/multicloud-k8s ]; then
-        rm -rf $DOWNLOAD_PATH/multicloud-k8s
+    clone_kud_repository
+    if [ "$1" == "v1" ] ; then
+        export KUD_ADDONS=multus
     fi
-
-    mkdir -p $DOWNLOAD_PATH
-    pushd $DOWNLOAD_PATH
-    git clone https://github.com/onap/multicloud-k8s.git
-    popd
 }
 
 function set_ssh_key {
@@ -30,12 +28,20 @@ function set_ssh_key {
 }
 
 function set_bm_kud {
-    pushd $DOWNLOAD_PATH/multicloud-k8s/kud/hosting_providers/vagrant/inventory
+    pushd ${KUDPATH}/kud/hosting_providers/vagrant/inventory
     HOST_IP=${HOST_IP:-$(hostname -I | cut -d ' ' -f 1)}
+    DOCKER_OPTIONS=""
+    if [[ ! -z "${DOCKER_REGISTRY_MIRRORS+x}" ]]; then
+       OPTIONS=""
+       for mirror in ${DOCKER_REGISTRY_MIRRORS}; do
+           OPTIONS="${OPTIONS} --registry-mirror=${mirror}"
+       done
+       DOCKER_OPTIONS="docker_options=\"${OPTIONS# }\""
+    fi
     if [ "$1" == "minimal" ] ; then
-    cat <<EOL > hosts.ini
+        cat <<EOL > hosts.ini
 [all]
-$HOSTNAME ansible_ssh_host=${HOST_IP} ansible_ssh_port=22
+$HOSTNAME ansible_ssh_host=${HOST_IP} ansible_ssh_port=22 ${DOCKER_OPTIONS}
 
 [kube-master]
 $HOSTNAME
@@ -51,9 +57,9 @@ kube-node
 kube-master
 EOL
     else
-    cat <<EOL > hosts.ini
+        cat <<EOL > hosts.ini
 [all]
-$HOSTNAME ansible_ssh_host=${HOST_IP} ansible_ssh_port=22
+$HOSTNAME ansible_ssh_host=${HOST_IP} ansible_ssh_port=22 ${DOCKER_OPTIONS}
 
 [kube-master]
 $HOSTNAME
@@ -82,22 +88,29 @@ EOL
 }
 
 function kud_install {
-    pushd $DOWNLOAD_PATH/multicloud-k8s/kud/hosting_providers/vagrant/
+    pushd ${KUDPATH}/kud/hosting_providers/vagrant/
     if [ "$1" == "all" ]; then
         sed -i -e 's/testing_enabled=${KUD_ENABLE_TESTS:-false}/testing_enabled=${KUD_ENABLE_TESTS:-true}/g' installer.sh
     fi
     ./installer.sh | tee kud_deploy.log
+
+    if [ "$1" == "bm" ]; then
+        for addon in ${KUD_ADDONS:-multus ovn4nfv nfd sriov qat cmk optane}; do
+            pushd ${KUDPATH}/kud/tests/
+                bash ${addon}.sh
+            popd
+        done
+    fi
     popd
 }
 
 function kud_reset {
-    pushd $DOWNLOAD_PATH/multicloud-k8s/kud/hosting_providers/vagrant/
-    ansible-playbook -i inventory/hosts.ini /opt/kubespray-2.10.4/reset.yml \
+    pushd ${KUDPATH}/kud/hosting_providers/vagrant/
+    ansible-playbook -i inventory/hosts.ini /opt/kubespray-${KUBESPRAY_VERSION}/reset.yml \
         --become --become-user=root -e reset_confirmation=yes
     popd
 }
 
-
 function verifier {
     APISERVER=$(kubectl config view --minify -o \
                     jsonpath='{.clusters[0].cluster.server}')
@@ -113,7 +126,7 @@ if [ "$1" == "reset" ] ; then
     exit 0
 fi
 
-get_kud_repo
+get_kud_repo $2
 set_ssh_key
 set_bm_kud $1
 kud_install $1