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