blob: fdc26150e206ae644a5a2ebe67b1c9cfa4d30ab5 [file] [log] [blame]
Gary Wu950a3232019-03-26 13:08:29 -07001#!/bin/bash -x
2#
3# Copyright 2018 Huawei Technologies Co., Ltd.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11
12# This is meant to be run from within the Rancher VM to completely
13# redeploy ONAP while reusing the existing k8s stack.
14#
15# This assumes that /root/integration-override.yaml is up-to-date.
16#
17# This script can also be used after a VM reboot, and will restart
18# helm server accordingly.
19
20export DEBIAN_FRONTEND=noninteractive
21
22usage() {
23 echo "Usage: $0 <namespace>" 1>&2;
24 echo "This will completely re-deploy ONAP, and delete and re-clone oom/ and integration/ directories."
25 exit 1;
26}
27
28if [ "$#" -ne 1 ]; then
29 usage
30fi
31
32
33NS=$1
34OOM_GERRIT_BRANCH=master
35OOM_GERRIT_REFSPEC=refs/heads/master
36INTEGRATION_GERRIT_BRANCH=master
37INTEGRATION_GERRIT_REFSPEC=refs/heads/master
Gary Wu950a3232019-03-26 13:08:29 -070038
39# Verify that k8s works
40if [ $(kubectl get pods --namespace kube-system | tail -n +2 | grep -c Running) -lt 6 ]; then
41 echo "[ERROR] Kubernetes is not healthy; aborting"
42 exit 1
43fi
44
Gary Wu950a3232019-03-26 13:08:29 -070045
46kubectl delete namespace $NS
47for op in secrets configmaps pvc pv services deployments statefulsets clusterrolebinding; do
48 kubectl delete $op -n $NS --all
49done
50helm undeploy dev --purge
51rm -rf /dockerdata-nfs/dev-*/
52
53
54# Clone OOM:
55cd ~
56rm -rf oom/
57git clone -b $OOM_GERRIT_BRANCH https://gerrit.onap.org/r/oom
58cd oom
59git fetch https://gerrit.onap.org/r/oom $OOM_GERRIT_REFSPEC
60git checkout FETCH_HEAD
61git checkout -b workarounds
62git log -1
63
64# Clone integration
65cd ~
66rm -rf integration/
67git clone -b $INTEGRATION_GERRIT_BRANCH https://gerrit.onap.org/r/integration
68cd integration
69git fetch https://gerrit.onap.org/r/integration $INTEGRATION_GERRIT_REFSPEC
70git checkout FETCH_HEAD
71git checkout -b workarounds
72git log -1
73
Gary Wu950a3232019-03-26 13:08:29 -070074git tag -a "deploy0" -m "initial deployment"
75
76
77# Run ONAP:
78cd ~/oom/kubernetes/
79
80if [ $(curl -s -o /dev/null -w "%{http_code}" 127.0.0.1:8879) -ne 200 ]; then
81 helm init --client-only
82 helm init --upgrade
83 helm serve &
84 sleep 10
85 helm repo add local http://127.0.0.1:8879
86 helm repo list
87fi
88make all
89rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
90helm search -l | grep local
91helm deploy dev local/onap -f ~/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f ~/integration-override.yaml --namespace onap | ts | tee -a ~/helm-deploy.log
92helm list