Adding onap4ks installation script in kud containerized installer 20/97320/6
authorKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>
Fri, 18 Oct 2019 16:08:50 +0000 (09:08 -0700)
committerKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>
Wed, 23 Oct 2019 21:33:28 +0000 (14:33 -0700)
Issue-ID: MULTICLOUD-867
Co-authored-by: Pramod Raghavendra Jayathirth <pramod.raghavendra.jayathirth@intel.com>
Co-authored-by: Ritu Sood <ritu.sood@intel.com>
Change-Id: I37b8112bdd5809f1ae0eaa58ddb0d834d395e8d8
Signed-off-by: Kuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>
kud/deployment_infra/images/multus-daemonset.yml
kud/deployment_infra/playbooks/configure-onap4k8s-reset.yml [new file with mode: 0644]
kud/deployment_infra/playbooks/configure-onap4k8s.yml [new file with mode: 0644]
kud/hosting_providers/containerized/installer.sh
kud/hosting_providers/containerized/inventory/group_vars/k8s-cluster.yml
kud/tests/onap4k8s.sh [new file with mode: 0755]

index ff44a21..0c41a05 100644 (file)
@@ -79,7 +79,7 @@ data:
       "delegates": [
         {
           "cniVersion": "0.3.1",
-          "name": "default-cni-network",
+          "name": "cni0",
           "plugins": [
             {
               "type": "flannel",
diff --git a/kud/deployment_infra/playbooks/configure-onap4k8s-reset.yml b/kud/deployment_infra/playbooks/configure-onap4k8s-reset.yml
new file mode 100644 (file)
index 0000000..6adaf2e
--- /dev/null
@@ -0,0 +1,56 @@
+---
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2018
+# 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
+##############################################################################
+
+- hosts: kube-master
+  tasks:
+    - name: Load kud variables
+      include_vars:
+        file: kud-vars.yml
+
+    - name: Change the onap4k8s directory and run helm delete
+      command: /usr/local/bin/helm delete --purge multicloud-onap8ks
+      register: helm_delete
+      args:
+        chdir: /opt/multicloud/deployments/helm/onap4k8s
+
+    - debug:
+        var: helm_delete.stdout_lines
+
+    - name: Change the onap4k8s directory and delete the ona4k8s-ns namespace
+      command: /usr/local/bin/kubectl delete ns onap4k8s-ns
+      register: delete_onap_ns
+      args:
+        chdir: /opt/multicloud/deployments/helm/onap4k8s
+
+    - debug:
+        var: delete_onap_ns.stdout_lines
+
+    - name: Change the onap4k8s directory and make clean
+      command: /usr/bin/make clean
+      register: make_clean
+      args:
+        chdir: /opt/multicloud/deployments/helm/onap4k8s
+
+    - debug:
+        var: make_clean.stdout_lines
+
+    - name: Change the onap4k8s directory and make repo-stop
+      command: /usr/bin/make repo-stop
+      register: make_repo_stop
+      args:
+        chdir: /opt/multicloud/deployments/helm/onap4k8s
+
+    - debug:
+        var: make_repo_stop.stdout_lines
+
+    - name: clean multicloud-k8s path
+      file:
+        state: absent
+        path: /opt/multicloud
diff --git a/kud/deployment_infra/playbooks/configure-onap4k8s.yml b/kud/deployment_infra/playbooks/configure-onap4k8s.yml
new file mode 100644 (file)
index 0000000..cacb41c
--- /dev/null
@@ -0,0 +1,47 @@
+---
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2018
+# 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
+##############################################################################
+
+- hosts: kube-master
+  tasks:
+    - name: Load kud variables
+      include_vars:
+        file: kud-vars.yml
+
+    - name: Getting onap4k8s code in /opt folder
+      git:
+        repo: 'https://github.com/onap/multicloud-k8s.git'
+        dest: /opt/multicloud
+
+    - name: Change the onap4k8s directory and run the command make repo
+      command: /usr/bin/make repo
+      register: make_repo
+      args:
+        chdir: /opt/multicloud/deployments/helm/onap4k8s
+
+    - debug:
+        var: make_repo.stdout_lines
+
+    - name: Change the onap4k8s directory and run the command make all
+      command: /usr/bin/make all
+      register: make_all
+      args:
+        chdir: /opt/multicloud/deployments/helm/onap4k8s
+
+    - debug:
+        var: make_all.stdout_lines
+
+    - name: Change the onap4k8s directory and run the command helm install
+      command: /usr/local/bin/helm install dist/packages/multicloud-k8s-5.0.0.tgz --name multicloud-onap8ks --namespace onap4k8s-ns --set service.type=NodePort
+      register: helm_install
+      args:
+        chdir: /opt/multicloud/deployments/helm/onap4k8s
+
+    - debug:
+        var: helm_install.stdout_lines
index 426c89a..52fe627 100755 (executable)
@@ -27,7 +27,7 @@ function install_prerequisites {
 
 # _install_ansible() - Install and Configure Ansible program
 function _install_ansible {
-    local version=$(grep "ansible_version" ${kud_playbooks}/kud-vars.yml | \
+    local version=$(grep "ansible_version" ${kud_playbooks}/kud-vars.yml |
         awk -F ': ' '{print $2}')
     mkdir -p /etc/ansible/
     pip install ansible==$version
@@ -100,6 +100,7 @@ function install_k8s {
 
 # install_addons() - Install Kubenertes AddOns
 function install_addons {
+    local plugins_name=$1
     source /etc/environment
     echo "Installing Kubernetes AddOns"
     ansible-galaxy install $verbose -r \
@@ -108,7 +109,7 @@ function install_addons {
     ansible-playbook $verbose -i \
         $kud_inventory $kud_playbooks/configure-kud.yml | \
         tee $cluster_log/setup-kud.log
-    for addon in ${KUD_ADDONS:-virtlet ovn4nfv nfd}; do
+    for addon in ${KUD_ADDONS:-virtlet ovn4nfv nfd $plugins_name}; do
         echo "Deploying $addon using configure-$addon.yml playbook.."
         ansible-playbook $verbose -i \
             $kud_inventory $kud_playbooks/configure-${addon}.yml | \
@@ -188,7 +189,7 @@ function install_pkg {
 
 function install_cluster {
     install_k8s $1
-    install_addons
+    install_addons $2
     echo "installed the addons"
     if ${KUD_PLUGIN_ENABLED:-false}; then
         install_plugin
@@ -197,18 +198,53 @@ function install_cluster {
     _print_kubernetes_info
 }
 
+function usage {
+    echo "installer usage:"
+    echo "./installer.sh --install_pkg - Install the required softwarepackage"
+    echo "./installer.sh --cluster <cluster name> \
+- Install k8s cluster with default plugins"
+    echo "./installer.sh --cluster <cluster name> \
+--plugins <plugin_1 plugin_2> - Install k8s cluster with default plugins \
+and additional plugins such as onap4k8s."
+}
+
+if [ $# -eq 0 ]; then
+    echo "Error: No arguments supplied"
+    usage
+    exit 1
+fi
+
+if [ -z "$1" ]; then
+    echo "Error: Null argument passed"
+    usage
+    exit 1
+fi
 
 if [ "$1" == "--install_pkg" ]; then
     export kud_inventory_folder=$kud_folder/inventory
     kud_inventory=$kud_inventory_folder/hosts.ini
     install_pkg
+    echo "install pkg"
     exit 0
 fi
 
 if [ "$1" == "--cluster" ]; then
+    if [ -z "${2-}"  ]; then
+        echo "Error: Cluster name is null"
+        usage
+        exit 1
+    fi
+
     cluster_name=$2
     kud_multi_cluster_path=/opt/kud/multi-cluster
     cluster_path=$kud_multi_cluster_path/$cluster_name
+    echo $cluster_path
+    if [ ! -d "${cluster_path}" ]; then
+        echo "Error: cluster_path ${cluster_path} doesn't exit"
+        usage
+        exit 1
+    fi
+
     cluster_log=$kud_multi_cluster_path/$cluster_name/log
     export kud_inventory_folder=$kud_folder/inventory/$cluster_name
     kud_inventory=$kud_inventory_folder/hosts.ini
@@ -218,6 +254,27 @@ if [ "$1" == "--cluster" ]; then
     cp $kud_multi_cluster_path/$cluster_name/hosts.ini $kud_inventory_folder/
     cp -rf $kud_folder/inventory/group_vars $kud_inventory_folder/
 
+    if [ -n "$3" ]; then
+        if [ "$3" == "--plugins" ]; then
+            if [ -z "${4-}"  ]; then
+                echo "Error: plugins arguments is null; Refer the usage"
+                usage
+                exit 1
+            fi
+            plugins_name=${@:4:$#}
+            install_cluster $cluster_name $plugins_name
+            exit 0
+        else
+            echo "Error: cluster argument should have plugins; \
+                Refer the usage"
+            usage
+            exit 1
+        fi
+    fi
     install_cluster $cluster_name
     exit 0
 fi
+
+echo "Error: Refer the installer usage"
+usage
+exit 1
index bc085b4..31d0d66 100644 (file)
@@ -71,3 +71,12 @@ local_release_dir: "/tmp/releases"
 # cannot access each over via ssh or you want to use local docker
 # images as a cache for multiple clusters.
 download_localhost: false
+
+# Subnet for cluster IPs
+kube_service_addresses: 10.244.0.0/18
+
+# Subnet for Pod IPs
+kube_pods_subnet: 10.244.64.0/18
+
+# disable localdns cache
+enable_nodelocaldns: false
diff --git a/kud/tests/onap4k8s.sh b/kud/tests/onap4k8s.sh
new file mode 100755 (executable)
index 0000000..702bed4
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2018
+# 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
+##############################################################################
+set -o errexit
+set -o pipefail
+
+source _functions.sh
+set +e
+
+master_ip=$(kubectl cluster-info | grep "Kubernetes master" | \
+    awk -F ":" '{print $2}' | awk -F "//" '{print $2}')
+onap_svc_node_port=30498
+declare -i timeout=18
+declare -i interval=10
+
+base_url="http://$master_ip:$onap_svc_node_port/v1"
+
+function check_onap_svc {
+    while ((timeout > 0)); do
+        echo "try $timeout: Wait for $interval seconds to check for onap svc"
+        sleep $interval
+        call_api "$base_url/healthcheck"
+        call_api_ret=$?
+        if [[ $call_api_ret -eq 0 ]]; then
+            echo "onap svc health check is success"
+            exit 0
+        fi
+        ((timeout-=1))
+    done
+}
+
+check_onap_svc
+echo "Failed to check for onap svc"
+exit 1