Fix PLA relations, add missing ENVs, and include it in the bundle
[osm/devops.git] / installers / full_install_osm.sh
index 22cb9f9..f268618 100755 (executable)
@@ -206,7 +206,6 @@ function uninstall_lightweight() {
             fi
             remove_k8s_namespace $OSM_STACK_NAME
         else
-
             remove_stack $OSM_STACK_NAME
             remove_stack osm_elk
         fi
@@ -214,7 +213,6 @@ function uninstall_lightweight() {
         newgrp docker << EONG
         docker image rm ${DOCKER_USER}/ro:${OSM_DOCKER_TAG}
         docker image rm ${DOCKER_USER}/lcm:${OSM_DOCKER_TAG}
-        docker image rm ${DOCKER_USER}/light-ui:${OSM_DOCKER_TAG}
         docker image rm ${DOCKER_USER}/keystone:${OSM_DOCKER_TAG}
         docker image rm ${DOCKER_USER}/nbi:${OSM_DOCKER_TAG}
         docker image rm ${DOCKER_USER}/mon:${OSM_DOCKER_TAG}
@@ -224,14 +222,10 @@ function uninstall_lightweight() {
 EONG
 
         if [ -n "$NGUI" ]; then
-            newgrp docker << EONG
-            docker image rm ${DOCKER_USER}/ng-ui:${OSM_DOCKER_TAG}
-EONG
+            sg docker -c "docker image rm ${DOCKER_USER}/ng-ui:${OSM_DOCKER_TAG}"
         else
-            newgrp docker << EONG
-            docker image rm ${DOCKER_USER}/light-ui:${OSM_DOCKER_TAG}
-EONG
-         fi
+            sg docker -c "docker image rm ${DOCKER_USER}/light-ui:${OSM_DOCKER_TAG}"
+        fi
 
         if [ -n "$KUBERNETES" ]; then
             OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}"
@@ -245,7 +239,7 @@ EONG
         $WORKDIR_SUDO rm -rf $OSM_DOCKER_WORK_DIR
         [ -z "$CONTROLLER_NAME" ] && sg lxd -c "juju destroy-controller --destroy-all-models --yes $OSM_STACK_NAME"
     fi
-    uninstall_osmclient
+    [ -z "$INSTALL_NOHOSTCLIENT" ] && uninstall_osmclient
     echo "Some docker images will be kept in case they are used by other docker stacks"
     echo "To remove them, just run 'docker image prune' in a terminal"
     return 0
@@ -254,7 +248,7 @@ EONG
 #Safe unattended install of iptables-persistent
 function check_install_iptables_persistent(){
     echo -e "\nChecking required packages: iptables-persistent"
-    if dpkg -l iptables-persistent &>/dev/null; then
+    if dpkg -l iptables-persistent &>/dev/null; then
         echo -e "    Not installed.\nInstalling iptables-persistent requires root privileges"
         echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
         echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
@@ -429,7 +423,7 @@ function juju_createcontroller() {
 }
 
 function juju_addk8s() {
-    cat .kube/config | juju add-k8s $OSM_VCA_K8S_CLOUDNAME --controller $OSM_STACK_NAME
+    cat .kube/config | juju add-k8s $OSM_VCA_K8S_CLOUDNAME --controller $OSM_STACK_NAME --storage openebs-hostpath
 }
 
 function juju_createproxy() {
@@ -803,11 +797,15 @@ function kube_secrets(){
     kubectl create secret generic pol-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/pol.env
 }
 
-#deploys osm pods and services
-function deploy_osm_services() {
+#taints K8s master node
+function taint_master_node() {
     K8S_MASTER=$(kubectl get nodes | awk '$3~/master/'| awk '{print $1}')
     kubectl taint node $K8S_MASTER node-role.kubernetes.io/master:NoSchedule-
     sleep 5
+}
+
+#deploys osm pods and services
+function deploy_osm_services() {
     kubectl apply -n $OSM_STACK_NAME -f $OSM_K8S_WORK_DIR
 }
 
@@ -825,6 +823,7 @@ function install_helm() {
     helm > /dev/null 2>&1
     if [ $? != 0 ] ; then
         # Helm is not installed. Install helm
+        echo "Helm is not installed, installing ..."
         curl https://get.helm.sh/helm-v2.15.2-linux-amd64.tar.gz --output helm-v2.15.2.tar.gz
         tar -zxvf helm-v2.15.2.tar.gz
         sudo mv linux-amd64/helm /usr/local/bin/helm
@@ -842,14 +841,17 @@ function install_helm() {
         helm init --service-account tiller
 
         # Wait for Tiller to be up and running. If timeout expires, continue installing
-        tiller_timeout=120; counter=0
+        tiller_timeout=120;
+        counter=0;
+        tiller_status=""
         while (( counter < tiller_timeout ))
         do
             tiller_status=`kubectl -n kube-system get deployment.apps/tiller-deploy --no-headers |  awk '{print $2'}`
-            ( [ ! -z "$tiller_status" ] && [ $tiller_status == "1/1" ] ) && break
-            num=$((counter + 2))
-            sleep 2
+            ( [ ! -z "$tiller_status" ] && [ $tiller_status == "1/1" ] ) && echo "Tiller ready" && break
+            counter=$((counter + 5))
+            sleep 5
         done
+        [ "$tiller_status" != "1/1" ] && echo "Tiller is NOT READY YET. Installation will continue"
     fi
 }
 
@@ -1011,12 +1013,6 @@ function add_local_k8scluster() {
 }
 
 function install_lightweight() {
-    [ "${OSM_STACK_NAME}" == "osm" ] || OSM_DOCKER_WORK_DIR="$OSM_WORK_DIR/stack/$OSM_STACK_NAME"
-    [ -n "$KUBERNETES" ] && OSM_K8S_WORK_DIR="$OSM_DOCKER_WORK_DIR/osm_pods" && OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}"
-    [ ! -d "$OSM_DOCKER_WORK_DIR" ] && $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR
-    [ ! -d "$OSM_DOCKER_WORK_DIR/osm_pla" -a -n "$INSTALL_PLA" ] && $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR/osm_pla
-    [ -n "$KUBERNETES" ] && $WORKDIR_SUDO cp -b $OSM_DEVOPS/installers/docker/cluster-config.yaml $OSM_DOCKER_WORK_DIR/cluster-config.yaml
-
     track checkingroot
     [ "$USER" == "root" ] && FATAL "You are running the installer as root. The installer is prepared to be executed as a normal user with sudo privileges."
     track noroot
@@ -1148,13 +1144,17 @@ EOF
     [ -n "$INSTALL_NODOCKER" ] || install_docker_ce
     track docker_ce
 
+    echo "Creating folders for installation"
+    [ ! -d "$OSM_DOCKER_WORK_DIR" ] && $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR
+    [ ! -d "$OSM_DOCKER_WORK_DIR/osm_pla" -a -n "$INSTALL_PLA" ] && $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR/osm_pla
+    [ -n "$KUBERNETES" ] && $WORKDIR_SUDO cp -b $OSM_DEVOPS/installers/docker/cluster-config.yaml $OSM_DOCKER_WORK_DIR/cluster-config.yaml
+
     #Installs Kubernetes and deploys osm services
     if [ -n "$KUBERNETES" ]; then
         install_kube
         track install_k8s
         init_kubeadm $OSM_DOCKER_WORK_DIR/cluster-config.yaml
         kube_config_dir
-       install_k8s_storage_class
         track init_k8s
     else
         #install_docker_compose
@@ -1162,11 +1162,6 @@ EOF
         track docker_swarm
     fi
 
-    if [ -n "$KUBERNETES" ]; then
-        juju_addk8s
-        track juju_addk8s
-    fi
-
     [ -z "$DOCKER_NOBUILD" ] && generate_docker_images
     track docker_build
 
@@ -1184,12 +1179,19 @@ EOF
         kube_secrets
         [ ! $OSM_DOCKER_TAG == "7" ] && parse_yaml $OSM_DOCKER_TAG
         namespace_vol
+        taint_master_node
         deploy_osm_services
         if [ -n "$INSTALL_PLA"]; then
             # optional PLA install
             deploy_osm_pla_service
         fi
         track deploy_osm_services_k8s
+        install_k8s_storageclass
+        track k8s_storageclass
+        juju_addk8s
+        track juju_addk8s
+        install_helm
+        track install_helm
         if [ -n "$INSTALL_K8S_MONITOR" ]; then
             # install OSM MONITORING
             install_k8s_monitoring
@@ -1670,6 +1672,8 @@ fi
 
 . $OSM_DEVOPS/common/all_funcs
 
+[ "${OSM_STACK_NAME}" == "osm" ] || OSM_DOCKER_WORK_DIR="$OSM_WORK_DIR/stack/$OSM_STACK_NAME"
+[ -n "$KUBERNETES" ] && OSM_K8S_WORK_DIR="$OSM_DOCKER_WORK_DIR/osm_pods" && OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}"
 [ -n "$INSTALL_LIGHTWEIGHT" ] && [ -n "$UNINSTALL" ] && uninstall_lightweight && echo -e "\nDONE" && exit 0
 [ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_ELK" ] && deploy_elk
 #[ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_PERFMON" ] && deploy_perfmon