2 ################################################################################
3 # Copyright (c) 2023 Nordix Foundation. #
4 # Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved. #
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 ################################################################################
19 # This script deploys NonRtRic components automatically
23 if [ "$#" -eq 1 ]; then
27 while [ -n "$1" ]; do # while loop starts
34 *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c
44 if [ -z "$OVERRIDEYAML" ];then
45 echo "****************************************************************************************************************"
47 echo "****************************************************************************************************************"
48 echo "RIC deployment without deployment recipe is currently disabled. Please specify an recipe with the -f option."
49 echo "****************************************************************************************************************"
54 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
57 rm $ROOT_DIR/../nonrtric/helm/*/charts/*.tgz
61 IS_HELM3=$(helm version -c --short|grep -e "^v3")
65 # Check for servcm plugin
66 helm plugin list | grep -q "^servecm"
69 helm plugin install https://github.com/jdolitsky/helm-servecm
73 # Start Helm local repo if there isn't one
74 HELM_REPO_PID=$(ps -x | grep "helm serve" | grep -v "grep" | awk '{print $1}')
75 if [ -z "$HELM_REPO_PID" ]; then
78 nohup helm serve >& /dev/null &
83 echo "Error: Please run the command with sudo as helm servecm needs to copy a file in location needing privilege"
86 eval $(helm env |grep HELM_REPOSITORY_CACHE)
87 echo yes > /tmp/ric-yes
88 nohup sudo sh -c "helm servecm --port=8879 --context-path=/charts --storage local --storage-local-rootdir $HELM_REPOSITORY_CACHE/local/ < /tmp/ric-yes " &
93 # Package common templates and serve it using Helm local repo
97 eval $(helm env |grep HELM_REPOSITORY_CACHE)
98 HELM_LOCAL_REPO="${HELM_REPOSITORY_CACHE}/local/"
100 HELM_HOME=$(helm home)
101 HELM_LOCAL_REPO="${HELM_HOME}/repository/local/"
105 rm $HELM_LOCAL_REPO/*
107 helm repo remove local
108 $ROOT_DIR/prepare-common-templates
110 COMPONENTS="controlpanel a1controller a1simulator policymanagementservice informationservice rappcatalogueservice rappcatalogueenhancedservice nonrtricgateway dmaapadapterservice dmaapmediatorservice helmmanager orufhrecovery ransliceassurance capifcore ranpm rappmanager"
111 for component in $COMPONENTS; do
112 echo "Packaging NONRTRIC component [$component]"
113 helm dep up $ROOT_DIR/../nonrtric/helm/$component
114 VERSION=$(cat $ROOT_DIR/../nonrtric/helm/$component/Chart.yaml | grep version | awk '{print $2}')
115 helm package -d /tmp $ROOT_DIR/../nonrtric/helm/$component
116 curl --data-binary @/tmp/$component-$VERSION.tgz http://127.0.0.1:8879/charts/api/charts
119 helm dep up $ROOT_DIR/../nonrtric/helm/nonrtric
121 helm repo index ${HELM_LOCAL_REPO}
123 # Make sure that helm local repo is added
124 helm repo add local http://127.0.0.1:8879/charts --force-update
126 echo "Finished Packaging NONRTRIC components [$COMPONENTS]"
130 COMMON_BLOCK=$(cat $OVERRIDEYAML | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
131 NAMESPACE_BLOCK=$(cat $OVERRIDEYAML | awk '/^ namespace:/{getline; while ($0 ~ /^ .*|^ *$/) {print $0; if (getline == 0) {break}}}')
132 NONRTRIC_NAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *nonrtric:/{print $2}')
133 RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
134 INSTALL_KONG=$(cat $OVERRIDEYAML | awk '/^ installKong:/{print $2}')
135 INSTALL_RANPM=$(cat $OVERRIDEYAML | awk '/^ installRanpm:/{print $2}')
136 echo "Chart name- $PARENT_CHART"
138 if ! kubectl get ns ${NONRTRIC_NAMESPACE:-nonrtric}> /dev/null 2>&1; then
139 kubectl create ns ${NONRTRIC_NAMESPACE:-nonrtric}
141 if ! kubectl get ns onap > /dev/null 2>&1; then
142 kubectl create ns onap
145 echo "Install Kong- $INSTALL_KONG"
147 if [ "$INSTALL_KONG" = true ];then
148 echo "Installing Kong"
149 helm repo add kong https://charts.konghq.com --force-update
151 helm install kong-nonrtric --namespace ${NONRTRIC_NAMESPACE:-nonrtric} kong/kong --set ingressController.installCRDs=false --set admin.enabled=true
154 kubectl create configmap -n ${NONRTRIC_NAMESPACE:-nonrtric} nonrtric-recipe --from-file=recipe=$OVERRIDEYAML
156 echo "Deploying NONRTRIC"
158 echo "Install Ranpm- $INSTALL_RANPM"
160 if [ "$INSTALL_RANPM" = true ];then
161 echo "Running install-ranpm.sh"
162 chmod +x ${ROOT_DIR}/../ranpm/install/install-ranpm.sh
163 ${ROOT_DIR}/../ranpm/install/install-ranpm.sh
164 echo "install-ranpm.sh completed"
168 if [ -z $IS_HELM3 ];then
169 HELM_NAME_OPT="--name"
172 echo "helm install -f $OVERRIDEYAML --namespace ${NONRTRIC_NAMESPACE:-nonrtric} ${HELM_NAME_OPT} ${RELEASE_PREFIX} $ROOT_DIR/../nonrtric/helm/nonrtric"
173 helm install -f $OVERRIDEYAML --namespace "${NONRTRIC_NAMESPACE:-nonrtric}" ${HELM_NAME_OPT} "${RELEASE_PREFIX}" "$ROOT_DIR/../nonrtric/helm/nonrtric"