Helm charts and apps for pm-setup
[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 "Installtion 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 KHOST=$(kube_get_controlplane_host)
42 if [ $? -ne 0 ]; then
43     echo $KHOST
44     echo "Exiting"
45     exit 1
46 fi
47
48 create_topic kafka-1-kafka-bootstrap.nonrtric:9092 pm-rapp 10
49
50 export KC_PORT=$(kube_get_nodeport keycloak nonrtric http)
51
52 . scripts/populate_keycloak.sh
53
54 cid="pm-rapp"
55 create_clients nonrtric-realm $cid
56 check_error $?
57 generate_client_secrets nonrtric-realm $cid
58 check_error $?
59
60 export PMRAPP_CLIENT_SECRET=$(< .sec_nonrtric-realm_$cid)
61
62 envsubst < helm/nrt-pm-rapp/values-template.yaml > helm/nrt-pm-rapp/values.yaml
63
64 echo " helm install..."
65 helm install --wait -n nonrtric nrt-pm-rapp helm/nrt-pm-rapp
66
67 echo "done"
68