From e397bbeaf49b51f18bf33095ba558ad5e67eb14a Mon Sep 17 00:00:00 2001 From: Richard Elias Date: Mon, 6 Aug 2018 09:18:56 +0200 Subject: ci: ONAP automated installation Script for automated ONAP installation at LAAS servers. JIRA: AUTO-49 Change-Id: I3b2c87d431924a81b86dca7a17226613b422a216 Signed-off-by: Richard Elias Signed-off-by: Martin Klozik --- ci/deploy-onap.sh | 342 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 342 insertions(+) create mode 100755 ci/deploy-onap.sh diff --git a/ci/deploy-onap.sh b/ci/deploy-onap.sh new file mode 100755 index 0000000..e886492 --- /dev/null +++ b/ci/deploy-onap.sh @@ -0,0 +1,342 @@ +#!/bin/bash +# +# Copyright 2018 Tieto +# +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Script for automated deployment of ONAP with Kubernetes at OPNFV LAAS +# environment. +# +# Usage: +# onap-deploy.sh +# +# where and are IP addresses of servers to be used +# for ONAP installation. +# +# NOTE: Following must be assured for all MASTER and SLAVE servers before +# onap-deploy.sh execution: +# 1) ssh access without a password +# 2) an "opnfv" user account with password-less sudo access must be +# available + +# +# Configuration +# +DOCKER_VERSION=17.03 +RANCHER_VERSION=1.6.14 +RANCHER_CLI_VER=0.6.11 +KUBECTL_VERSION=1.8.10 +HELM_VERSION=2.8.2 + +MASTER=$1 +SERVERS=$* + +BRANCH='master' +ENVIRON='onap' + +# +# Installation +# +echo "INSTALLING DOCKER ON ALL MACHINES" +echo "$SERVERS" + +for MACHINE in $SERVERS; +do +ssh opnfv@"$MACHINE" "bash -s" < /etc/systemd/system/docker.service.d/docker.conf + + systemctl daemon-reload + systemctl restart docker + apt-mark hold docker-ce + + for SERVER in $SERVERS; + do + echo "\$SERVER $ENVIRON\$(echo \$SERVER | cut -d. -f 4 )" >> /etc/hosts + done + + hostname $ENVIRON\$(echo $MACHINE | cut -d. -f 4 ) + + echo "DOCKER INSTALLED ON $MACHINE" +DOCKERINSTALL +done +wait + +echo "INSTALLING RANCHER ON MASTER" +echo "$MASTER" + +ssh opnfv@"$MASTER" "bash -s" <>/etc/exports +service nfs-kernel-server restart + +echo "Waiting 10 minutes for Rancher to setup at \$(date)" +sleep 600 +echo "Installing RANCHER CLI, KUBERNETES ENV on RANCHER" +wget https://github.com/rancher/cli/releases/download/v${RANCHER_CLI_VER}-rc2\ +/rancher-linux-amd64-v${RANCHER_CLI_VER}-rc2.tar.gz +tar -zxvf rancher-linux-amd64-v${RANCHER_CLI_VER}-rc2.tar.gz +cp rancher-v${RANCHER_CLI_VER}-rc2/rancher . + +API_RESPONSE=\`curl -s 'http://127.0.0.1:8080/v2-beta/apikey'\ + -d '{"type":"apikey","accountId":"1a1","name":"autoinstall",\ + "description":"autoinstall","created":null,"kind":null,\ + "removeTime":null,"removed":null,"uuid":null}'\` +# Extract and store token +echo "API_RESPONSE: \${API_RESPONSE}" +KEY_PUBLIC=\`echo \${API_RESPONSE} | jq -r .publicValue\` +KEY_SECRET=\`echo \${API_RESPONSE} | jq -r .secretValue\` +echo "publicValue: \$KEY_PUBLIC secretValue: \$KEY_SECRET" + +export RANCHER_URL=http://${MASTER}:8080 +export RANCHER_ACCESS_KEY=\$KEY_PUBLIC +export RANCHER_SECRET_KEY=\$KEY_SECRET + +./rancher env ls +echo "Creating kubernetes environment named ${ENVIRON}" +./rancher env create -t kubernetes $ENVIRON > kube_env_id.json +PROJECT_ID=\$( ~/.kube/config + +echo "docker run --rm --privileged\ + -v /var/run/docker.sock:/var/run/docker.sock\ + -v /var/lib/rancher:/var/lib/rancher\ + \$REGISTRATION_DOCKER\ + \$RANCHER_URL/v1/scripts/\$REGISTRATION_TOKEN"\ + > /tmp/rancher_register_host +chown opnfv /tmp/rancher_register_host + +RANCHERINSTALL +wait + +echo "REGISTER TOKEN" +HOSTREGTOKEN=$(ssh opnfv@"$MASTER" cat /tmp/rancher_register_host) +echo "$HOSTREGTOKEN" + +echo "REGISTERING HOSTS WITH RANCHER ENVIRONMENT '$ENVIRON'" +echo "$SERVERS" + +for MACHINE in $SERVERS; +do +ssh opnfv@"$MACHINE" "bash -s" < \${FAILED_PODS_LIMIT} at the \${COUNTER}th"\ + " 15 sec interval out of \${MAX_WAIT_PERIODS}" + echo "" + COUNTER=\$((\$COUNTER + 1 )) + if [ "\$MAX_WAIT_PERIODS" -eq \$COUNTER ]; then + FAILED_PODS_LIMIT=800 + fi +done + +echo "Report on non-running containers" +PENDING=\$(kubectl get pods --all-namespaces | grep -E '0/|1/2') +PENDING_COUNT=\$(kubectl get pods --all-namespaces | grep -E '0/|1/2' | wc -l) +PENDING_COUNT_AAI=\$(kubectl get pods -n $ENVIRON | grep aai- \ +| grep -E '0/|1/2' | wc -l) + +echo "Check filebeat 2/2 count for ELK stack logging consumption" +FILEBEAT=\$(kubectl get pods --all-namespaces -a | grep 2/) +echo "\${FILEBEAT}" +echo "sleep 5 min - to allow rest frameworks to finish at \$(date)" +sleep 300 +echo "List of ONAP Modules" +LIST_ALL=\$(kubectl get pods --all-namespaces -a --show-all ) +echo "\${LIST_ALL}" +echo "run healthcheck 2 times to warm caches and frameworks"\ + "so rest endpoints report properly - see OOM-447" + +echo "curl with aai cert to cloud-region PUT" +curl -X PUT https://127.0.0.1:30233/aai/v11/cloud-infrastructure/\ +cloud-regions/cloud-region/CloudOwner/RegionOne \ +--data "@aai-cloud-region-put.json" \ +-H "authorization: Basic TW9kZWxMb2FkZXI6TW9kZWxMb2FkZXI=" \ +-H "X-TransactionId:jimmy-postman" \ +-H "X-FromAppId:AAI" \ +-H "Content-Type:application/json" \ +-H "Accept:application/json" \ +--cacert aaiapisimpledemoopenecomporg_20171003.crt -k + +echo "get the cloud region back" +curl -X GET https://127.0.0.1:30233/aai/v11/cloud-infrastructure/\ +cloud-regions/ \ +-H "authorization: Basic TW9kZWxMb2FkZXI6TW9kZWxMb2FkZXI=" \ +-H "X-TransactionId:jimmy-postman" \ +-H "X-FromAppId:AAI" \ +-H "Content-Type:application/json" \ +-H "Accept:application/json" \ +--cacert aaiapisimpledemoopenecomporg_20171003.crt -k + +# OOM-484 - robot scripts moved +cd oom/kubernetes/robot +echo "run healthcheck prep 1" +# OOM-722 adds namespace parameter +if [ "$BRANCH" == "amsterdam" ]; then + ./ete-k8s.sh health > ~/health1.out +else + ./ete-k8s.sh $ENVIRON health > ~/health1.out +fi +echo "sleep 5 min at \$(date)" +sleep 300 +echo "run healthcheck prep 2" +if [ "$BRANCH" == "amsterdam" ]; then + ./ete-k8s.sh health > ~/health2.out +else + ./ete-k8s.sh $ENVIRON health > ~/health2.out +fi +echo "run healthcheck for real - wait a further 5 min at \$(date)" +sleep 300 +if [ "$BRANCH" == "amsterdam" ]; then + ./ete-k8s.sh health +else + ./ete-k8s.sh $ENVIRON health +fi +OOMDEPLOY +wait +echo "Finished install, ruturned from Master" +exit 0 -- cgit 1.2.3-korg