summaryrefslogtreecommitdiffstats
path: root/kud
diff options
context:
space:
mode:
authorRitu Sood <Ritu.Sood@intel.com>2019-10-24 22:22:57 +0000
committerGerrit Code Review <gerrit@onap.org>2019-10-24 22:22:57 +0000
commit09aa5765d5667dbe46947dd9d4f41c9063b44646 (patch)
treef9490feb458a64dd4b90628f4ec239fb16d65d2a /kud
parenteb414b9d43a9b094ce9445b35933f00343d40b8f (diff)
parent47224ff96fea8e5a4cda20e5211f66adceb87d10 (diff)
Merge "Adding onap4ks installation script in kud containerized installer"
Diffstat (limited to 'kud')
-rw-r--r--kud/deployment_infra/images/multus-daemonset.yml2
-rw-r--r--kud/deployment_infra/playbooks/configure-onap4k8s-reset.yml56
-rw-r--r--kud/deployment_infra/playbooks/configure-onap4k8s.yml47
-rwxr-xr-xkud/hosting_providers/containerized/installer.sh63
-rw-r--r--kud/hosting_providers/containerized/inventory/group_vars/k8s-cluster.yml9
-rwxr-xr-xkud/tests/onap4k8s.sh40
6 files changed, 213 insertions, 4 deletions
diff --git a/kud/deployment_infra/images/multus-daemonset.yml b/kud/deployment_infra/images/multus-daemonset.yml
index ff44a217..0c41a052 100644
--- a/kud/deployment_infra/images/multus-daemonset.yml
+++ b/kud/deployment_infra/images/multus-daemonset.yml
@@ -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
index 00000000..6adaf2ee
--- /dev/null
+++ b/kud/deployment_infra/playbooks/configure-onap4k8s-reset.yml
@@ -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
index 00000000..cacb41c9
--- /dev/null
+++ b/kud/deployment_infra/playbooks/configure-onap4k8s.yml
@@ -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
diff --git a/kud/hosting_providers/containerized/installer.sh b/kud/hosting_providers/containerized/installer.sh
index 426c89a0..52fe6279 100755
--- a/kud/hosting_providers/containerized/installer.sh
+++ b/kud/hosting_providers/containerized/installer.sh
@@ -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
diff --git a/kud/hosting_providers/containerized/inventory/group_vars/k8s-cluster.yml b/kud/hosting_providers/containerized/inventory/group_vars/k8s-cluster.yml
index bc085b4e..31d0d669 100644
--- a/kud/hosting_providers/containerized/inventory/group_vars/k8s-cluster.yml
+++ b/kud/hosting_providers/containerized/inventory/group_vars/k8s-cluster.yml
@@ -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
index 00000000..702bed46
--- /dev/null
+++ b/kud/tests/onap4k8s.sh
@@ -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