blob: 1d46f025d78b57327870042b18283bb57a486e86 [file] [log] [blame]
Gary Wuae7b4a72018-10-30 11:41:52 -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 Wuc1e14832018-10-31 10:15:13 -070038DOCKER_MANIFEST=""
Gary Wuae7b4a72018-10-30 11:41:52 -070039
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
46if [ ! -f /dockerdata-nfs/rancher_agent_cmd.sh ]; then
47 cp /root/rancher_agent_cmd.sh /dockerdata-nfs
48fi
49
50
51kubectl delete namespace $NS
52for op in secrets configmaps pvc pv services deployments statefulsets clusterrolebinding; do
53 kubectl delete $op -n $NS --all
54done
55helm undeploy dev --purge
56rm -rf /dockerdata-nfs/dev-*/
57
58
59# Clone OOM:
60cd ~
61rm -rf oom/
62git clone -b $OOM_GERRIT_BRANCH https://gerrit.onap.org/r/oom
63cd oom
64git fetch https://gerrit.onap.org/r/oom $OOM_GERRIT_REFSPEC
65git checkout FETCH_HEAD
66git checkout -b workarounds
67git log -1
68
69# Clone integration
70cd ~
71rm -rf integration/
72git clone -b $INTEGRATION_GERRIT_BRANCH https://gerrit.onap.org/r/integration
73cd integration
74git fetch https://gerrit.onap.org/r/integration $INTEGRATION_GERRIT_REFSPEC
75git checkout FETCH_HEAD
76git checkout -b workarounds
77git log -1
78
Gary Wuc1e14832018-10-31 10:15:13 -070079if [ ! -z "$DOCKER_MANIFEST" ]; then
Gary Wuae7b4a72018-10-30 11:41:52 -070080 cd version-manifest/src/main/scripts
Gary Wuc1e14832018-10-31 10:15:13 -070081 ./update-oom-image-versions.sh ../resources/$DOCKER_MANIFEST ~/oom/
Gary Wuae7b4a72018-10-30 11:41:52 -070082fi
83
84cd ~/oom
85git diff
86git commit -a -m "apply manifest versions"
87git tag -a "deploy0" -m "initial deployment"
88
89
90# Run ONAP:
91cd ~/oom/kubernetes/
92
93if [ $(curl -s -o /dev/null -w "%{http_code}" 127.0.0.1:8879) -ne 200 ]; then
94 helm init --client-only
95 helm init --upgrade
96 helm serve &
97 sleep 10
98 helm repo add local http://127.0.0.1:8879
99 helm repo list
100fi
101make all
102rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
103helm search -l | grep local
104helm 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
105helm list
106