aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-os-chef/scripts/k8s/deploy_k8s_sdc.sh
blob: 83c2950ebc35520a799256c75e29fc014cf87967 (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
75
76
77
78
79
80
#!/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
}

check_pods_status()
{ 
    num_of_pods=$1
    status=0
    while [ ${status} -ne ${num_of_pods} ]
    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
}

# 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

check_pods_status 4

# 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"

check_pods_status 5

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"
l-Scalar-Plain">name: sdc-fe env: - name: ENVNAME value: AUTO - name: HOST_IP valueFrom: fieldRef: fieldPath: status.podIP image: {{ .Values.image.sdcFrontend }} imagePullPolicy: {{ .Values.pullPolicy }} volumeMounts: - mountPath: /usr/share/elasticsearch/data/ name: sdc-sdc-es-es - mountPath: /root/chef-solo/environments/ name: sdc-environments - mountPath: /etc/localtime name: sdc-localtime readOnly: true - mountPath: /var/lib/jetty/logs name: sdc-logs - mountPath: /var/log/onap name: sdc-logs-2 - mountPath: /root/chef-solo/cookbooks/sdc-catalog-fe/recipes/FE_2_setup_configuration.rb name: sdc-fe-config subPath: FE_2_setup_configuration.rb - mountPath: /tmp/logback.xml name: sdc-logback lifecycle: postStart: exec: command: ["/bin/sh", "-c", "export LOG=wait_logback.log; touch $LOG; export SRC=/tmp/logback.xml; export DST=/var/lib/jetty/config/catalog-fe/; while [ ! -e $DST ]; do echo 'Waiting for $DST...' >> $LOG; sleep 5; done; sleep 2; /bin/cp -f $SRC $DST; echo 'Done' >> $LOG"] ports: - containerPort: 9443 - containerPort: 8181 readinessProbe: tcpSocket: port: 8181 initialDelaySeconds: 5 periodSeconds: 10 - image: {{ .Values.image.filebeat }} imagePullPolicy: {{ .Values.pullPolicy }} name: filebeat-onap volumeMounts: - mountPath: /usr/share/filebeat/filebeat.yml name: filebeat-conf subPath: filebeat.yml - mountPath: /var/log/onap name: sdc-logs-2 - mountPath: /usr/share/filebeat/data name: sdc-data-filebeat volumes: - name: filebeat-conf configMap: name : sdc-filebeat-configmap - name: sdc-logs-2 emptyDir: {} - name: sdc-data-filebeat emptyDir: {} - name: sdc-logback configMap: name : sdc-log-fe-configmap - name: sdc-sdc-es-es hostPath: path: {{ .Values.dataRootDir }}/{{ .Values.nsPrefix }}/sdc/sdc-es/ES - name: sdc-environments configMap: name: sdc-environments-configmap defaultMode: 0755 - name: sdc-localtime hostPath: path: /etc/localtime - name: sdc-logs hostPath: path: {{ .Values.dataRootDir }}/{{ .Values.nsPrefix }}/sdc/logs - name: sdc-fe-config configMap: name: sdc-fe-configmap defaultMode: 0755 imagePullSecrets: - name: "{{ .Values.nsPrefix }}-docker-registry-key" #{{ end }}