blob: 83c2950ebc35520a799256c75e29fc014cf87967 [file] [log] [blame]
Areli Fuss471a29702018-02-01 13:09:07 +02001#!/bin/sh
2set -x
3
4check_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
Areli Fusseeec5042018-02-09 00:08:52 +020015check_pods_status()
16{
17 num_of_pods=$1
18 status=0
19 while [ ${status} -ne ${num_of_pods} ]
20 do
21 status=$(sudo kubectl get pods --namespace kube-system -o json \
22 | jq -r '
23 .items[]
24 | select(.status.phase == "Running" and
25 ([ .status.conditions[] | select(.type == "Ready" and .status == "True") ]
26 | length ) == 1 )
27 | .metadata.namespace + "/" + .metadata.name
28 ' \
29 | wc -l )
30 sleep 3
31 done
32}
Areli Fuss471a29702018-02-01 13:09:07 +020033
34# Should be removed while private dockers (maven build) will be available:
35echo "[INFO] ONAP Docker login"
36sudo docker login -u docker -p docker nexus3.onap.org:10001
37check_status $? "Onap docker registry login"
38
39# Verify the kube-system pods are running:
40# kube-addon-manager, kube-dns, kubernetes-dashboard, storage-provisioner, tiller-deploy
41echo "[INFO] Wait for Kubernetes Service ..."
42cd ../../kubernetes
Areli Fusseeec5042018-02-09 00:08:52 +020043
44check_pods_status 4
Areli Fuss471a29702018-02-01 13:09:07 +020045
46# Create namespace
47echo "[INFO] Check Namespace existence"
48exist_namespace=$( sudo kubectl get namespaces | grep onap-sdc | grep Active | wc -l )
49if [ ${exist_namespace} -eq 0 ]; then
50 sudo kubectl create namespace onap-sdc
51 check_status $? "Create namespace"
52fi
53
54echo "[INFO] Running helm init"
55sudo helm init
56check_status $? "Helm init"
57
Areli Fusseeec5042018-02-09 00:08:52 +020058check_pods_status 5
Areli Fuss471a29702018-02-01 13:09:07 +020059
60printf "[INFO] Wait for helm to get ready\n"
61helm_health=1
62while [ ${helm_health} -ne 0 ]
63do
64 sudo helm version | grep "Server" >/dev/null 2>&1
65 helm_health=$?
66 sleep 5
67done
68
69# Remove previous chart
70exist_chart=$( sudo helm ls onap-sdc -q | wc -l )
71if [ ${exist_chart} -ne 0 ];then
72 echo "[INFO] Delete the existing onap-sdc chart"
73 sudo helm del --purge onap-sdc
74 check_status $? "Delete chart"
75fi
76
77# Install updated chart
78echo "[INFO] Create onap-sdc deployment"
79sudo helm install sdc --name onap-sdc
80check_status $? "Install chart"