5c7837df1ee4f9b1b4be3488662b2fbb2066e075
[ric-plt/ric-dep.git] / bin / install
1 #!/bin/bash
2 ################################################################################
3 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
4 #   Copyright (c) 2019 Nokia.                                                  #
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 ################################################################################
18 while [ -n "$1" ]; do # while loop starts
19
20     case "$1" in
21
22     -f) OVERRIDEYAML=$2
23         shift
24         ;;
25     -c) LIST_OF_COMPONENTS=$2
26         shift
27         ;;
28     *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c
29
30     esac
31
32     shift
33
34 done
35
36 if [ -z "$OVERRIDEYAML" ];then
37     echo "****************************************************************************************************************"
38     echo "                                                     ERROR                                                      "
39     echo "****************************************************************************************************************"
40     echo "RIC deployment without deployment recipe is currently disabled. Please specify an recipe with the -f option."
41     echo "****************************************************************************************************************"
42     exit 1
43 fi
44
45 HAS_COMMON_PACKAGE=$(helm search local/ric-common | grep ric-common)
46
47 if [ -z "$HAS_COMMON_PACKAGE" ];then
48     echo "****************************************************************************************************************"
49     echo "                                                     ERROR                                                      "
50     echo "****************************************************************************************************************"
51     echo "Can't locate the ric-common helm package in the local repo. Please make sure that it is properly installed."
52     echo "****************************************************************************************************************"
53     exit 1
54 fi
55
56
57
58
59
60
61
62
63
64
65
66 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
67 COMMON_BLOCK=$(cat $OVERRIDEYAML | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
68 NAMESPACE_BLOCK=$(cat $OVERRIDEYAML | awk '/^  namespace:/{getline; while ($0 ~ /^    .*|^ *$/) {print $0; if (getline == 0) {break}}}')
69 PLTNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *platform:/{print $2}')
70 INFRANAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *infra:/{print $2}')
71 XAPPNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *xapp:/{print $2}')
72 RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
73 COMPONENTS=${LIST_OF_COMPONENTS:-"infrastructure appmgr rtmgr dbaas1 e2mgr e2term a1mediator submgr vespamgr rsm jaegeradapter"}
74 echo "Deploying RIC infra components [$COMPONENTS]"
75
76
77 if ! kubectl get ns ${PLTNAMESPACE:-ricplt}> /dev/null 2>&1; then
78     kubectl create ns ${PLTNAMESPACE:-ricplt}
79 fi
80 if ! kubectl get ns ${INFRANAMESPACE:-ricinfra}> /dev/null 2>&1; then
81     kubectl create ns ${INFRANAMESPACE:-ricinfra}
82 fi
83 if ! kubectl get ns ${XAPPNAMESPACE:-ricxapp}> /dev/null 2>&1; then
84     kubectl create ns ${XAPPNAMESPACE:-ricxapp}
85 fi
86
87 kubectl create configmap -n ${PLTNAMESPACE:-ricplt} ricplt-recipe --from-file=recipe=$OVERRIDEYAML
88
89
90 for component in $COMPONENTS; do
91     helm dep up $DIR/../helm/$component
92     helm install -f $OVERRIDEYAML --namespace "${PLTNAMESPACE:-ricplt}" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component
93     sleep 3
94 done