aboutsummaryrefslogtreecommitdiffstats
path: root/deployment/heat/onap-oom/scripts/redeploy.sh
blob: 2ec3e1756824d7710dee07ddfa1a25e882e59046 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash -x
#
# Copyright 2018 Huawei Technologies Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#

# This is meant to be run from within the Rancher VM to completely
# redeploy ONAP while reusing the existing k8s stack.
#
# This assumes that /root/integration-override.yaml is up-to-date.
#
# This script can also be used after a VM reboot, and will restart
# helm server accordingly.

export DEBIAN_FRONTEND=noninteractive

usage() {
    echo "Usage: $0 <namespace>" 1>&2;
    echo "This will completely re-deploy ONAP, and delete and re-clone oom/ and integration/ directories."
    exit 1;
}

if [ "$#" -ne 1 ]; then
   usage
fi


NS=$1
OOM_GERRIT_BRANCH=master
OOM_GERRIT_REFSPEC=refs/heads/master
INTEGRATION_GERRIT_BRANCH=master
INTEGRATION_GERRIT_REFSPEC=refs/heads/master


# Verify that k8s works
if [ $(kubectl get pods --namespace kube-system | tail -n +2 | grep -c Running) -lt 6 ]; then
    echo "[ERROR] Kubernetes is not healthy; aborting"
    exit 1
fi

if [ ! -f /dockerdata-nfs/rancher_agent_cmd.sh ]; then
    cp /root/rancher_agent_cmd.sh /dockerdata-nfs
fi


kubectl delete namespace $NS
for op in secrets configmaps pvc pv services deployments statefulsets clusterrolebinding; do
    kubectl delete $op -n $NS --all
done
helm undeploy dev --purge
rm -rf /dockerdata-nfs/dev-*/


# Clone OOM:
cd ~
rm -rf oom/
git clone -b $OOM_GERRIT_BRANCH https://gerrit.onap.org/r/oom
cd oom
git fetch https://gerrit.onap.org/r/oom $OOM_GERRIT_REFSPEC
git checkout FETCH_HEAD
git checkout -b workarounds
git log -1

# Clone integration
cd ~
rm -rf integration/
git clone -b $INTEGRATION_GERRIT_BRANCH https://gerrit.onap.org/r/integration
cd integration
git fetch https://gerrit.onap.org/r/integration $INTEGRATION_GERRIT_REFSPEC
git checkout FETCH_HEAD
git checkout -b workarounds
git log -1

if [ ! -z "__docker_manifest__" ]; then
    cd version-manifest/src/main/scripts
    ./update-oom-image-versions.sh ../resources/__docker_manifest__ ~/oom/
fi

cd ~/oom
git diff
git commit -a -m "apply manifest versions"
git tag -a "deploy0" -m "initial deployment"


# Run ONAP:
cd ~/oom/kubernetes/

if [ $(curl -s -o /dev/null -w "%{http_code}" 127.0.0.1:8879) -ne 200 ]; then
    helm init --client-only
    helm init --upgrade
    helm serve &
    sleep 10
    helm repo add local http://127.0.0.1:8879
    helm repo list
fi
make all
rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
helm search -l | grep local
helm 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
helm list