Minor fix for RANPM
[nonrtric/plt/ranpm.git] / install / install-pm-rapp.sh
1 #!/bin/bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2023 Nordix Foundation. 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=================================================
18 #
19
20
21
22 echo "Installing pmrapp"
23
24 . scripts/kube_get_controlplane_host.sh
25 . scripts/kube_get_nodeport.sh
26 . scripts/create_topic.sh
27
28 # Generic error printout function
29 # args: <numeric-response-code> <descriptive-string>
30 check_error() {
31     if [ $1 -ne 0 ]; then
32         echo "Failed: $2"
33         echo "Exiting..."
34         exit 1
35     fi
36 }
37
38 echo "Creating client in keycloak"
39
40 # Find host and port to keycloak
41 export KUBERNETESHOST=$(kube_get_controlplane_host)
42 if [ $? -ne 0 ]; then
43     echo $KUBERNETESHOST
44     echo "Exiting"
45     exit 1
46 fi
47
48 create_topic kafka-1-kafka-bootstrap.nonrtric:9092 rapp-topic 10
49
50 . scripts/populate_keycloak.sh
51
52 cid="pm-rapp"
53 create_clients nonrtric-realm $cid
54 check_error $?
55 generate_client_secrets nonrtric-realm $cid
56 check_error $?
57
58 export PMRAPP_CLIENT_SECRET=$(< .sec_nonrtric-realm_$cid)
59
60 envsubst < helm/nrt-pm-rapp/values-template.yaml > helm/nrt-pm-rapp/values.yaml
61
62 echo " helm install..."
63 helm install --wait -f helm/global-values.yaml -n nonrtric nrt-pm-rapp helm/nrt-pm-rapp
64
65 echo "done"
66