Areli Fuss | 471a2970 | 2018-02-01 13:09:07 +0200 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | set -x |
| 3 | |
| 4 | check_status() |
| 5 | { |
| 6 | local rc=$1 |
| 7 | shift |
| 8 | local comment="$@" |
| 9 | if [ ${rc} != 0 ]; then |
| 10 | echo "[ERR] Failure detected - ${comment}. Aborting !" |
| 11 | exit 255 |
| 12 | fi |
| 13 | } |
| 14 | |
| 15 | |
| 16 | # Should be removed while private dockers (maven build) will be available: |
| 17 | echo "[INFO] ONAP Docker login" |
| 18 | sudo docker login -u docker -p docker nexus3.onap.org:10001 |
| 19 | check_status $? "Onap docker registry login" |
| 20 | |
| 21 | # Verify the kube-system pods are running: |
| 22 | # kube-addon-manager, kube-dns, kubernetes-dashboard, storage-provisioner, tiller-deploy |
| 23 | echo "[INFO] Wait for Kubernetes Service ..." |
| 24 | cd ../../kubernetes |
| 25 | status=0 |
| 26 | while [ ${status} -ne 5 ] |
| 27 | do |
| 28 | status=$(sudo kubectl get pods --namespace kube-system -o json \ |
| 29 | | jq -r ' |
| 30 | .items[] |
| 31 | | select(.status.phase == "Running" and |
| 32 | ([ .status.conditions[] | select(.type == "Ready" and .status == "True") ] |
| 33 | | length ) == 1 ) |
| 34 | | .metadata.namespace + "/" + .metadata.name |
| 35 | ' \ |
| 36 | | wc -l ) |
| 37 | sleep 3 |
| 38 | done |
| 39 | |
| 40 | # Create namespace |
| 41 | echo "[INFO] Check Namespace existence" |
| 42 | exist_namespace=$( sudo kubectl get namespaces | grep onap-sdc | grep Active | wc -l ) |
| 43 | if [ ${exist_namespace} -eq 0 ]; then |
| 44 | sudo kubectl create namespace onap-sdc |
| 45 | check_status $? "Create namespace" |
| 46 | fi |
| 47 | |
| 48 | echo "[INFO] Running helm init" |
| 49 | sudo helm init |
| 50 | check_status $? "Helm init" |
| 51 | |
| 52 | set -x |
| 53 | |
| 54 | printf "[INFO] Wait for helm to get ready\n" |
| 55 | helm_health=1 |
| 56 | while [ ${helm_health} -ne 0 ] |
| 57 | do |
| 58 | sudo helm version | grep "Server" >/dev/null 2>&1 |
| 59 | helm_health=$? |
| 60 | sleep 5 |
| 61 | done |
| 62 | |
| 63 | # Remove previous chart |
| 64 | exist_chart=$( sudo helm ls onap-sdc -q | wc -l ) |
| 65 | if [ ${exist_chart} -ne 0 ];then |
| 66 | echo "[INFO] Delete the existing onap-sdc chart" |
| 67 | sudo helm del --purge onap-sdc |
| 68 | check_status $? "Delete chart" |
| 69 | fi |
| 70 | |
| 71 | # Install updated chart |
| 72 | echo "[INFO] Create onap-sdc deployment" |
| 73 | sudo helm install sdc --name onap-sdc |
| 74 | check_status $? "Install chart" |