Donald Hunter | b4b9a05 | 2018-09-17 09:17:27 +0100 | [diff] [blame] | 1 | #!/bin/sh |
Jakub Latusek | e2b7dd3 | 2020-10-21 13:36:29 +0200 | [diff] [blame] | 2 | {{/* |
Donald Hunter | b4b9a05 | 2018-09-17 09:17:27 +0100 | [diff] [blame] | 3 | # ================================================================================ |
| 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 Latusek | e2b7dd3 | 2020-10-21 13:36:29 +0200 | [diff] [blame] | 18 | */}} |
Donald Hunter | b4b9a05 | 2018-09-17 09:17:27 +0100 | [diff] [blame] | 19 | |
| 20 | # Install PNDA in Openstack with Heat templates |
| 21 | # Expects: |
| 22 | # Input files for components to be installed in /inputs |
| 23 | |
| 24 | if [ "z{{ .Values.enabled }}" != "ztrue" ] |
| 25 | then |
| 26 | echo |
| 27 | echo "PNDA bootstrap is disabled - skipping pnda-cli launch" |
| 28 | echo |
| 29 | exit 0 |
| 30 | fi |
| 31 | |
| 32 | set -ex |
| 33 | |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 34 | CLUSTER_PREFIX="{{ include "common.release" . }}-{{ include "common.namespace" . }}-pnda" |
Donald Hunter | b4b9a05 | 2018-09-17 09:17:27 +0100 | [diff] [blame] | 35 | DATANODES="{{ .Values.pnda.dataNodes }}" |
| 36 | KAFKANODES="{{ .Values.pnda.kafkaNodes }}" |
| 37 | VERSION="{{ .Values.pnda.version }}" |
| 38 | KEYPAIR_NAME="{{ .Values.pnda_keypair_name }}" |
| 39 | KEYFILE="$KEYPAIR_NAME.pem" |
| 40 | |
| 41 | cd /pnda-cli |
| 42 | |
| 43 | cp /inputs/pnda_env.yaml . |
| 44 | cp /secrets/pnda.pem $KEYFILE |
| 45 | chmod 600 $KEYFILE |
| 46 | |
| 47 | (cd tools && ./gen-certs.py) |
| 48 | |
| 49 | KUBE_API="https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT_HTTPS/api/v1" |
| 50 | KUBE_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) |
| 51 | |
| 52 | for i in 1 2 3 4 5 6 7 8 9 |
| 53 | do |
Julien Barbot | 00520bc | 2018-11-13 19:08:56 +0100 | [diff] [blame] | 54 | 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 Hunter | b4b9a05 | 2018-09-17 09:17:27 +0100 | [diff] [blame] | 60 | |
Julien Barbot | 00520bc | 2018-11-13 19:08:56 +0100 | [diff] [blame] | 61 | if [ "x${MIRROR_IP}" != "xnull" -a "x${MIRROR_PORT}" != "xnull" ]; then |
| 62 | PNDA_MIRROR="http://$MIRROR_IP:$MIRROR_PORT" |
Donald Hunter | b4b9a05 | 2018-09-17 09:17:27 +0100 | [diff] [blame] | 63 | break |
| 64 | fi |
| 65 | sleep 5 |
| 66 | done |
| 67 | |
Julien Barbot | 00520bc | 2018-11-13 19:08:56 +0100 | [diff] [blame] | 68 | [ -z "${PNDA_MIRROR}" ] && { echo "Unable to get PNDA mirror IP:PORT"; exit 1; } |
Donald Hunter | b4b9a05 | 2018-09-17 09:17:27 +0100 | [diff] [blame] | 69 | |
| 70 | sed -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" |