blob: ab7eaa3f768300a01940dfd6dcf1a4c4f9914376 [file] [log] [blame]
Donald Hunterb4b9a052018-09-17 09:17:27 +01001#!/bin/sh
2# ================================================================================
3# Copyright (c) 2018 Cisco Systems. All rights reserved.
4# ================================================================================
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# ============LICENSE_END=========================================================
17
18# Install PNDA in Openstack with Heat templates
19# Expects:
20# Input files for components to be installed in /inputs
21
22if [ "z{{ .Values.enabled }}" != "ztrue" ]
23then
24 echo
25 echo "PNDA bootstrap is disabled - skipping pnda-cli launch"
26 echo
27 exit 0
28fi
29
30set -ex
31
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010032CLUSTER_PREFIX="{{ include "common.release" . }}-{{ include "common.namespace" . }}-pnda"
Donald Hunterb4b9a052018-09-17 09:17:27 +010033DATANODES="{{ .Values.pnda.dataNodes }}"
34KAFKANODES="{{ .Values.pnda.kafkaNodes }}"
35VERSION="{{ .Values.pnda.version }}"
36KEYPAIR_NAME="{{ .Values.pnda_keypair_name }}"
37KEYFILE="$KEYPAIR_NAME.pem"
38
39cd /pnda-cli
40
41cp /inputs/pnda_env.yaml .
42cp /secrets/pnda.pem $KEYFILE
43chmod 600 $KEYFILE
44
45(cd tools && ./gen-certs.py)
46
47KUBE_API="https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT_HTTPS/api/v1"
48KUBE_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
49
50for i in 1 2 3 4 5 6 7 8 9
51do
Julien Barbot00520bc2018-11-13 19:08:56 +010052 MIRROR_IP=$(curl -s $KUBE_API/namespaces/{{ include "common.namespace" . }}/pods \
53 --header "Authorization: Bearer $KUBE_TOKEN" \
54 --insecure | jq -r '.items[].status | select(.containerStatuses != null) | select(.containerStatuses[].ready and .containerStatuses[].name=="dcae-pnda-mirror") | .hostIP')
55 MIRROR_PORT=$(curl -s $KUBE_API/namespaces/{{ include "common.namespace" . }}/services/dcae-pnda-mirror \
56 --header "Authorization: Bearer $KUBE_TOKEN" \
57 --insecure | jq -r '.spec.ports[] | select(.name=="dcae-pnda-mirror") | .nodePort')
Donald Hunterb4b9a052018-09-17 09:17:27 +010058
Julien Barbot00520bc2018-11-13 19:08:56 +010059 if [ "x${MIRROR_IP}" != "xnull" -a "x${MIRROR_PORT}" != "xnull" ]; then
60 PNDA_MIRROR="http://$MIRROR_IP:$MIRROR_PORT"
Donald Hunterb4b9a052018-09-17 09:17:27 +010061 break
62 fi
63 sleep 5
64done
65
Julien Barbot00520bc2018-11-13 19:08:56 +010066[ -z "${PNDA_MIRROR}" ] && { echo "Unable to get PNDA mirror IP:PORT"; exit 1; }
Donald Hunterb4b9a052018-09-17 09:17:27 +010067
68sed -i -e 's?CLIENT_IP/32?CLIENT_IP?' bootstrap-scripts/package-install.sh
69
70./cli/pnda-cli.py create -e $CLUSTER_PREFIX -f pico -n $DATANODES -k $KAFKANODES \
71 -b $VERSION -s $KEYPAIR_NAME --set "mirrors.PNDA_MIRROR=$PNDA_MIRROR"