blob: d18fab970dc551a870294867c1bc1033127d8a6d [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
38DOCKER_MANIFEST=""
39
40# Verify that k8s works
41if [ $(kubectl get pods --namespace kube-system | tail -n +2 | grep -c Running) -lt 6 ]; then
42 echo "[ERROR] Kubernetes is not healthy; aborting"
43 exit 1
44fi
45
Gary Wu950a3232019-03-26 13:08:29 -070046
47kubectl delete namespace $NS
48for op in secrets configmaps pvc pv services deployments statefulsets clusterrolebinding; do
49 kubectl delete $op -n $NS --all
50done
51helm undeploy dev --purge
52rm -rf /dockerdata-nfs/dev-*/
53
54
55# Clone OOM:
56cd ~
57rm -rf oom/
58git clone -b $OOM_GERRIT_BRANCH https://gerrit.onap.org/r/oom
59cd oom
60git fetch https://gerrit.onap.org/r/oom $OOM_GERRIT_REFSPEC
61git checkout FETCH_HEAD
62git checkout -b workarounds
63git log -1
64
65# Clone integration
66cd ~
67rm -rf integration/
68git clone -b $INTEGRATION_GERRIT_BRANCH https://gerrit.onap.org/r/integration
69cd integration
70git fetch https://gerrit.onap.org/r/integration $INTEGRATION_GERRIT_REFSPEC
71git checkout FETCH_HEAD
72git checkout -b workarounds
73git log -1
74
75if [ ! -z "$DOCKER_MANIFEST" ]; then
76 cd version-manifest/src/main/scripts
77 ./update-oom-image-versions.sh ../resources/$DOCKER_MANIFEST ~/oom/
78fi
79
80cd ~/oom
81git diff
82git commit -a -m "apply manifest versions"
83git tag -a "deploy0" -m "initial deployment"
84
85
86# Run ONAP:
87cd ~/oom/kubernetes/
88
89if [ $(curl -s -o /dev/null -w "%{http_code}" 127.0.0.1:8879) -ne 200 ]; then
90 helm init --client-only
91 helm init --upgrade
92 helm serve &
93 sleep 10
94 helm repo add local http://127.0.0.1:8879
95 helm repo list
96fi
97make all
98rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
99helm search -l | grep local
100helm 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
101helm list
102