diff options
Diffstat (limited to 'deployment/heat/onap-oom/scripts')
-rwxr-xr-x[-rw-r--r--] | deployment/heat/onap-oom/scripts/cleanup.sh | 2 | ||||
-rwxr-xr-x | deployment/heat/onap-oom/scripts/deploy.sh | 40 | ||||
-rwxr-xr-x | deployment/heat/onap-oom/scripts/gen-onap-oom-yaml.sh | 2 | ||||
-rwxr-xr-x | deployment/heat/onap-oom/scripts/redeploy.sh | 106 |
4 files changed, 132 insertions, 18 deletions
diff --git a/deployment/heat/onap-oom/scripts/cleanup.sh b/deployment/heat/onap-oom/scripts/cleanup.sh index 4c84e3566..7c2a1e29f 100644..100755 --- a/deployment/heat/onap-oom/scripts/cleanup.sh +++ b/deployment/heat/onap-oom/scripts/cleanup.sh @@ -15,7 +15,7 @@ if [ $COMPONENT == "dcae" ] || [ $COMPONENT == "DCAE" ]; then kubectl delete service consul -n onap fi -for op in secrets configmaps pvc pv services deployments statefulsets; do +for op in secrets configmaps pvc pv services deployments statefulsets clusterrolebinding; do ARRAY=(`kubectl get $op -n onap | grep dev-$COMPONENT | awk '{print $1}'`) for i in ${ARRAY[*]}; do kubectl delete $op -n onap $i diff --git a/deployment/heat/onap-oom/scripts/deploy.sh b/deployment/heat/onap-oom/scripts/deploy.sh index 459af34bc..c3a73c763 100755 --- a/deployment/heat/onap-oom/scripts/deploy.sh +++ b/deployment/heat/onap-oom/scripts/deploy.sh @@ -156,28 +156,36 @@ ssh-keygen -R $RANCHER_IP sleep 2m ssh -o StrictHostKeychecking=no -i $SSH_KEY ubuntu@$RANCHER_IP "sed -u '/Cloud-init.*finished/q' <(tail -n+0 -f /var/log/cloud-init-output.log)" -for n in $(seq 1 8); do - echo "Wait count $n of 8" - sleep 15m - ssh -i $SSH_KEY ubuntu@$RANCHER_IP 'sudo su -l root -c "/root/oom/kubernetes/robot/ete-k8s.sh onap health"' - RESULT=$? - if [ $RESULT -eq 0 ]; then - break - fi +PREV_RESULT=0 +for n in $(seq 1 20); do + RESULT=$(ssh -i $SSH_KEY ubuntu@$RANCHER_IP 'sudo su -c "kubectl -n onap get pods"' | grep -vE 'Running|Complete|NAME' | wc -l) + if [[ $? -eq 0 && ( $RESULT -eq 0 || $RESULT -eq $PREV_RESULT ) ]]; then + break + fi + sleep 15m + PREV_RESULT=$RESULT +done + +PREV_RESULT=0 +for n in $(seq 1 20); do + echo "Wait for HEALTHCHECK count $n of 10" + ROBOT_POD=$(ssh -i $SSH_KEY ubuntu@$RANCHER_IP 'sudo su -c "kubectl --namespace onap get pods"' | grep robot | sed 's/ .*//') + ssh -i $SSH_KEY ubuntu@$RANCHER_IP 'sudo su -l root -c "/root/oom/kubernetes/robot/ete-k8s.sh onap health"' + RESULT=$? + if [[ $RESULT -lt 10 && ( $RESULT -eq 0 || $RESULT -eq $PREV_RESULT ) ]]; then + break + fi + sleep 15m + PREV_RESULT=$RESULT done -ROBOT_POD=$(ssh -i $SSH_KEY ubuntu@$RANCHER_IP 'sudo su -c "kubectl --namespace onap get pods"' | grep robot | sed 's/ .*//') if [ "$ROBOT_POD" == "" ]; then - exit 1 + exit 1 fi LOG_DIR=$(echo "kubectl exec -n onap $ROBOT_POD -- ls -1t /share/logs | grep health | head -1" | ssh -i $SSH_KEY ubuntu@$RANCHER_IP sudo su) -if [ "$LOG_DIR" == "" ]; then - exit 1 -fi - echo "kubectl cp -n onap $ROBOT_POD:share/logs/$LOG_DIR /tmp/robot/logs/$LOG_DIR" | ssh -i $SSH_KEY ubuntu@$RANCHER_IP sudo su -rsync -e "ssh -i $SSH_KEY" -avtz ubuntu@$RANCHER_IP:/tmp/robot/logs/$LOG_DIR/ $WORKSPACE/archives/ - echo "Browse Robot results at http://$K8S_IP:30209/logs/$LOG_DIR/" +mkdir -p $WORKSPACE/archives/healthcheck +rsync -e "ssh -i $SSH_KEY" -avtz ubuntu@$RANCHER_IP:/tmp/robot/logs/$LOG_DIR/ $WORKSPACE/archives/healthcheck exit 0 diff --git a/deployment/heat/onap-oom/scripts/gen-onap-oom-yaml.sh b/deployment/heat/onap-oom/scripts/gen-onap-oom-yaml.sh index 0afd48085..570011128 100755 --- a/deployment/heat/onap-oom/scripts/gen-onap-oom-yaml.sh +++ b/deployment/heat/onap-oom/scripts/gen-onap-oom-yaml.sh @@ -101,7 +101,7 @@ for VM_NUM in $(seq 3); do VM_TYPE=etcd HOST_LABEL=etcd VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml done -for VM_NUM in $(seq 2); do +for VM_NUM in $(seq 1); do VM_TYPE=orch HOST_LABEL=orchestration VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml done diff --git a/deployment/heat/onap-oom/scripts/redeploy.sh b/deployment/heat/onap-oom/scripts/redeploy.sh new file mode 100755 index 000000000..1d46f025d --- /dev/null +++ b/deployment/heat/onap-oom/scripts/redeploy.sh @@ -0,0 +1,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 +DOCKER_MANIFEST="" + +# 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 + |