2 ################################################################################
3 # Copyright (c) 2020 Nordix Foundation. #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
18 # This script deploys NonRtRic components automatically
22 if [ "$#" -eq 1 ]; then
26 while [ -n "$1" ]; do # while loop starts
33 *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c
43 if [ -z "$OVERRIDEYAML" ];then
44 echo "****************************************************************************************************************"
46 echo "****************************************************************************************************************"
47 echo "RIC deployment without deployment recipe is currently disabled. Please specify an recipe with the -f option."
48 echo "****************************************************************************************************************"
53 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
56 rm $ROOT_DIR/../nonrtric/helm/*/charts/*.tgz
60 IS_HELM3=$(helm version -c --short|grep -e "^v3")
64 # Check for servcm plugin
65 helm plugin list | grep -q "^servecm"
68 helm plugin install https://github.com/jdolitsky/helm-servecm
72 # Start Helm local repo if there isn't one
73 HELM_REPO_PID=$(ps -x | grep "helm serve" | grep -v "grep" | awk '{print $1}')
74 if [ -z "$HELM_REPO_PID" ]; then
77 nohup helm serve >& /dev/null &
82 echo "Error: Please run the command with sudo as helm servecm needs to copy a file in location needing privilege"
85 eval $(helm env |grep HELM_REPOSITORY_CACHE)
86 echo yes > /tmp/ric-yes
87 nohup sudo sh -c "helm servecm --port=8879 --context-path=/charts --storage local --storage-local-rootdir $HELM_REPOSITORY_CACHE/local/ < /tmp/ric-yes " &
92 # Package common templates and serve it using Helm local repo
96 eval $(helm env |grep HELM_REPOSITORY_CACHE)
97 HELM_LOCAL_REPO="${HELM_REPOSITORY_CACHE}/local/"
99 HELM_HOME=$(helm home)
100 HELM_LOCAL_REPO="${HELM_HOME}/repository/local/"
104 rm $HELM_LOCAL_REPO/*
106 helm repo remove local
107 $ROOT_DIR/prepare-common-templates
109 COMPONENTS="controlpanel a1controller a1simulator policymanagementservice informationservice rappcatalogueservice nonrtricgateway dmaapadapterservice dmaapmediatorservice helmmanager orufhrecovery ransliceassurance capifcore"
110 for component in $COMPONENTS; do
111 echo "Packaging NONRTRIC component [$component]"
112 helm dep up $ROOT_DIR/../nonrtric/helm/$component
113 VERSION=$(cat $ROOT_DIR/../nonrtric/helm/$component/Chart.yaml | grep version | awk '{print $2}')
114 helm package -d /tmp $ROOT_DIR/../nonrtric/helm/$component
115 curl --data-binary @/tmp/$component-$VERSION.tgz http://127.0.0.1:8879/charts/api/charts
118 helm dep up $ROOT_DIR/../nonrtric/helm/nonrtric
120 helm repo index ${HELM_LOCAL_REPO}
122 # Make sure that helm local repo is added
123 helm repo add local http://127.0.0.1:8879/charts --force-update
125 echo "Finished Packaging NONRTRIC components [$COMPONENTS]"
129 COMMON_BLOCK=$(cat $OVERRIDEYAML | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
130 NAMESPACE_BLOCK=$(cat $OVERRIDEYAML | awk '/^ namespace:/{getline; while ($0 ~ /^ .*|^ *$/) {print $0; if (getline == 0) {break}}}')
131 NONRTRIC_NAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *nonrtric:/{print $2}')
132 RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
133 INSTALL_KONG=$(cat $OVERRIDEYAML | awk '/^ installKong:/{print $2}')
134 echo "Chart name- $PARENT_CHART"
136 if ! kubectl get ns ${NONRTRIC_NAMESPACE:-nonrtric}> /dev/null 2>&1; then
137 kubectl create ns ${NONRTRIC_NAMESPACE:-nonrtric}
139 if ! kubectl get ns onap > /dev/null 2>&1; then
140 kubectl create ns onap
143 echo "Install Kong- $INSTALL_KONG"
145 if [ "$INSTALL_KONG" = true ];then
146 echo "Installing Kong"
147 helm repo add kong https://charts.konghq.com --force-update
149 helm install kong-nonrtric --namespace ${NONRTRIC_NAMESPACE:-nonrtric} kong/kong --set ingressController.installCRDs=false --set admin.enabled=true
152 kubectl create configmap -n ${NONRTRIC_NAMESPACE:-nonrtric} nonrtric-recipe --from-file=recipe=$OVERRIDEYAML
154 echo "Deploying NONRTRIC"
157 if [ -z $IS_HELM3 ];then
158 HELM_NAME_OPT="--name"
161 echo "helm install -f $OVERRIDEYAML --namespace ${NONRTRIC_NAMESPACE:-nonrtric} ${HELM_NAME_OPT} ${RELEASE_PREFIX} $ROOT_DIR/../nonrtric/helm/nonrtric"
162 helm install -f $OVERRIDEYAML --namespace "${NONRTRIC_NAMESPACE:-nonrtric}" ${HELM_NAME_OPT} "${RELEASE_PREFIX}" "$ROOT_DIR/../nonrtric/helm/nonrtric"