Gary Wu | ae7b4a7 | 2018-10-30 11:41:52 -0700 | [diff] [blame] | 1 | #!/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 | |
| 20 | export DEBIAN_FRONTEND=noninteractive |
| 21 | |
| 22 | usage() { |
| 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 | |
| 28 | if [ "$#" -ne 1 ]; then |
| 29 | usage |
| 30 | fi |
| 31 | |
| 32 | |
| 33 | NS=$1 |
| 34 | OOM_GERRIT_BRANCH=master |
| 35 | OOM_GERRIT_REFSPEC=refs/heads/master |
| 36 | INTEGRATION_GERRIT_BRANCH=master |
| 37 | INTEGRATION_GERRIT_REFSPEC=refs/heads/master |
Gary Wu | c1e1483 | 2018-10-31 10:15:13 -0700 | [diff] [blame] | 38 | DOCKER_MANIFEST="" |
Gary Wu | ae7b4a7 | 2018-10-30 11:41:52 -0700 | [diff] [blame] | 39 | |
| 40 | # Verify that k8s works |
| 41 | if [ $(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 |
| 44 | fi |
| 45 | |
| 46 | if [ ! -f /dockerdata-nfs/rancher_agent_cmd.sh ]; then |
| 47 | cp /root/rancher_agent_cmd.sh /dockerdata-nfs |
| 48 | fi |
| 49 | |
| 50 | |
| 51 | kubectl delete namespace $NS |
| 52 | for op in secrets configmaps pvc pv services deployments statefulsets clusterrolebinding; do |
| 53 | kubectl delete $op -n $NS --all |
| 54 | done |
| 55 | helm undeploy dev --purge |
| 56 | rm -rf /dockerdata-nfs/dev-*/ |
| 57 | |
| 58 | |
| 59 | # Clone OOM: |
| 60 | cd ~ |
| 61 | rm -rf oom/ |
| 62 | git clone -b $OOM_GERRIT_BRANCH https://gerrit.onap.org/r/oom |
| 63 | cd oom |
| 64 | git fetch https://gerrit.onap.org/r/oom $OOM_GERRIT_REFSPEC |
| 65 | git checkout FETCH_HEAD |
| 66 | git checkout -b workarounds |
| 67 | git log -1 |
| 68 | |
| 69 | # Clone integration |
| 70 | cd ~ |
| 71 | rm -rf integration/ |
| 72 | git clone -b $INTEGRATION_GERRIT_BRANCH https://gerrit.onap.org/r/integration |
| 73 | cd integration |
| 74 | git fetch https://gerrit.onap.org/r/integration $INTEGRATION_GERRIT_REFSPEC |
| 75 | git checkout FETCH_HEAD |
| 76 | git checkout -b workarounds |
| 77 | git log -1 |
| 78 | |
Gary Wu | c1e1483 | 2018-10-31 10:15:13 -0700 | [diff] [blame] | 79 | if [ ! -z "$DOCKER_MANIFEST" ]; then |
Gary Wu | ae7b4a7 | 2018-10-30 11:41:52 -0700 | [diff] [blame] | 80 | cd version-manifest/src/main/scripts |
Gary Wu | c1e1483 | 2018-10-31 10:15:13 -0700 | [diff] [blame] | 81 | ./update-oom-image-versions.sh ../resources/$DOCKER_MANIFEST ~/oom/ |
Gary Wu | ae7b4a7 | 2018-10-30 11:41:52 -0700 | [diff] [blame] | 82 | fi |
| 83 | |
| 84 | cd ~/oom |
| 85 | git diff |
| 86 | git commit -a -m "apply manifest versions" |
| 87 | git tag -a "deploy0" -m "initial deployment" |
| 88 | |
| 89 | |
| 90 | # Run ONAP: |
| 91 | cd ~/oom/kubernetes/ |
| 92 | |
| 93 | if [ $(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 |
| 100 | fi |
| 101 | make all |
| 102 | rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/ |
| 103 | helm search -l | grep local |
| 104 | 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 |
| 105 | helm list |
| 106 | |