summaryrefslogtreecommitdiffstats
path: root/sdc-os-chef/scripts/k8s/deploy_k8s_sdc.sh
blob: 9a7b57747b17efdb7f1a3b6933f056366b689851 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
set -x

check_status()
{
  local rc=$1
  shift
  local comment="$@"
  if [ ${rc} != 0 ]; then
    echo "[ERR] Failure detected - ${comment}.  Aborting !"
    exit 255
  fi
}


# Should be removed while private dockers (maven build) will be available:
echo "[INFO] ONAP Docker login"
sudo docker login -u docker -p docker nexus3.onap.org:10001
check_status $? "Onap docker registry login"

# Verify the kube-system pods are running:
# kube-addon-manager, kube-dns, kubernetes-dashboard, storage-provisioner, tiller-deploy
echo "[INFO] Wait for Kubernetes Service ..." 
cd ../../kubernetes
status=0
while [ ${status} -ne 5 ]
do 
  status=$(sudo kubectl get pods --namespace kube-system -o json \
  | jq -r '
    .items[]
    | select(.status.phase == "Running" and 
    ([ .status.conditions[] | select(.type == "Ready" and .status == "True") ]
    | length ) == 1 )
    | .metadata.namespace + "/" + .metadata.name
    ' \
  |  wc -l )
  sleep 3
done

# Create namespace 
echo "[INFO] Check Namespace existence"
exist_namespace=$( sudo kubectl get namespaces  | grep onap-sdc | grep Active | wc -l )
if [ ${exist_namespace} -eq 0 ]; then
  sudo kubectl create namespace onap-sdc
  check_status $? "Create namespace"
fi

echo "[INFO] Running helm init"
sudo helm init
check_status $? "Helm init"

set -x

printf "[INFO] Wait for helm to get ready\n"
helm_health=1
while [ ${helm_health} -ne 0 ]
do 
  sudo helm version | grep "Server" >/dev/null 2>&1
  helm_health=$?
  sleep 5
done

# Remove previous chart
exist_chart=$( sudo helm ls onap-sdc -q | wc -l )
if [ ${exist_chart} -ne 0 ];then
  echo "[INFO] Delete the existing onap-sdc chart"
  sudo helm del --purge onap-sdc
  check_status $? "Delete chart"
fi

# Install updated chart
echo "[INFO] Create onap-sdc deployment"
sudo helm install sdc --name onap-sdc
check_status $? "Install chart"