2 ################################################################################
3 # Copyright (c) 2019 AT&T Intellectual Property. #
4 # Copyright (c) 2019 Nokia. #
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 #
10 # http://www.apache.org/licenses/LICENSE-2.0 #
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 ################################################################################
20 while [ -n "$1" ]; do # while loop starts
27 -c) LIST_OF_COMPONENTS=$2
30 *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c
39 if [ -z "$OVERRIDEYAML" ];then
40 echo "****************************************************************************************************************"
42 echo "****************************************************************************************************************"
43 echo "RIC deployment without deployment recipe is currently disabled. Please specify an recipe with the -f option."
44 echo "****************************************************************************************************************"
50 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
51 GLOBAL_BLOCK=$(cat $OVERRIDEYAML | awk '/^global:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
52 NAMESPACE_BLOCK=$(cat $OVERRIDEYAML | awk '/^ namespace:/{getline; while ($0 ~ /^ .*|^ *$/) {print $0; if (getline == 0) {break}}}')
53 NAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *infra:/{print $2}')
54 RELEASE_PREFIX=$(echo "$GLOBAL_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
55 COMPONENTS=${LIST_OF_COMPONENTS:-"chartmuseum"}
58 NODENAME=$(kubectl get node | awk 'NR>1{print $1}')
61 for f in $NODENAME; do
62 LABEL=$(kubectl describe node $f | grep local-storage)
63 if [ ! -z "$LABEL" ]; then
68 FOUND_STORAGECLASS=$(grep storageclass $OVERRIDEYAML)
70 if ! $LABELFOUND && [ -z "$FOUND_STORAGECLASS" ]; then
71 echo "***********************************************************************************************"
72 echo "* ERROR!!!!!!!!!!!!! *"
73 echo "***********************************************************************************************"
74 echo "* Nodes label \"local-storage=enable\" is not found in any of the cluster node. *"
75 echo "* Please pick a node and label it using the following command. *"
76 echo "* kubectl label --overwrite nodes <YOUR_NODE_NAME> local-storage=enable *"
77 echo "***********************************************************************************************"
82 if [ -z "$FOUND_STORAGECLASS" ] && $LABELFOUND; then
84 DATAPATH=$(cat $DIR/../helm/chartmuseum/values.yaml | grep datapath | awk '{ print $2}' )
87 if [ ! -z $OVERRIDEYAML ]; then
88 DATAPATHOVERRIDE=$(cat $OVERRIDEYAML | grep datapath | awk '{ print $2}' )
91 if [ ! -z "$DATAPATHOVERRIDE" ]; then
92 DATAPATH=$DATAPATHOVERRIDE
95 if [ ! -d "$DATAPATH" ]; then
96 mkdir -p $DATAPATH || { echo "Directory $DATAPATH does not exist and you don't have permission to create it. Please choose a different datapath." ; exit 1 ; }
99 echo "***********************************************************************************************"
100 echo "* WARNING!!!!!!!!!!!!! *"
101 echo "***********************************************************************************************"
102 echo "* Chartmuseume will use local storage. Please make sure that directory *"
104 echo "* contains the proper files. *"
105 echo "***********************************************************************************************"
108 echo "Deploying RIC infra components [$COMPONENTS]"
111 COMMON_CHART_VERSION=$(cat $DIR/../../../ric-common/Common-Template/helm/ric-common/Chart.yaml | grep version | awk '{print $2}')
112 helm package -d /tmp $DIR/../../../ric-common/Common-Template/helm/ric-common
115 for component in $COMPONENTS; do
117 mkdir -p $DIR/../helm/$component/charts/
118 cp /tmp/ric-common-$COMMON_CHART_VERSION.tgz $DIR/../helm/$component/charts/
119 helm install -f $OVERRIDEYAML --namespace "${NAMESPACE}" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component