blob: 99661a9b6bc1375ff179fbb75c503201704246d2 [file] [log] [blame]
stark, steven6754bc12019-09-19 15:43:00 -07001#!/bin/bash
2# Copyright 2019 AT&T Intellectual Property. All rights reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
17
18CONF=$1
19
20if [ -z "$CONF" ]; then
21 echo "Configuration file required, exiting..."
22 exit 1
23fi
24
25. $CONF
26
27kubectl create configmap onap-bootstrap --from-file=$DIR/post-install/ --from-file=kubeconfig=$KUBECONFIG --from-file=onap.conf=$CONF
28
29cat <<EOF | kubectl apply -f -
30apiVersion: v1
31kind: Pod
32metadata:
33 name: onap-bootstrap
34spec:
35 containers:
36 - name: onap-bootstrap
37 image: alpine
38 env:
39 - name: BUILD_DIR
40 value: "/tmp/onap-bootstrap-files"
41 volumeMounts:
42 - name: onap-bootstrap
43 mountPath: /onap-bootstrap
44 command: ["/bin/sh"]
45 args:
46 - -c
47 - apk update && \
48 apk add bash && \
49 apk add git && \
50 apk add jq && \
51 apk add curl && \
52 apk add openjdk8 && \
53 apk add openjdk8-jre && \
54 export PATH=$PATH:/usr/lib/jvm/java-1.8-openjdk/bin && \
55 curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl && \
56 chmod +x ./kubectl && \
57 mv ./kubectl /usr/local/bin/kubectl && \
58 cd /onap-bootstrap && \
59 . onap.conf && \
60 export KUBECONFIG=kubeconfig && \
61 sh -c "/onap-bootstrap/bootstrap.sh"
62 restartPolicy: Never
63 volumes:
64 - name: onap-bootstrap
65 configMap:
66 name: onap-bootstrap
67 defaultMode: 0777
68EOF
69
70echo "Creating pod to Bootstrap ONAP with OpenStack details."
71echo "This might take a while if OpenStack is still launching..."
72
73podstatus=""
74COUNTER=0
75
76while [ "$podstatus" != "Error" ] && [ "$podstatus" != "Completed" ] && [ $COUNTER -lt 60 ]; do
77 podstatus=`kubectl get pods | grep onap-bootstrap | head -1 | awk '{print $3}'`
78 echo "onap-bootstrap is $podstatus"
79 COUNTER=$((COUNTER +1))
80 sleep 30
81done
82
83echo "onap-bootstrap pod logs available at /tmp/onap-bootstrap-log"
84kubectl logs onap-bootstrap > /tmp/onap-bootstrap-log
85
86kubectl delete pod onap-bootstrap
87kubectl delete configmap onap-bootstrap
88
89if [ "$podstatus" = "Error" ]; then
90 echo "ONAP bootstrap failed!"
91fi