#!/bin/bash ################################################################################ # Copyright (c) 2020 Nordix Foundation. # # # # Licensed under the Apache License, Version 2.0 (the "License"); # # you may not use this file except in compliance with the License. # # You may obtain a copy of the License at # # # # http://www.apache.org/licenses/LICENSE-2.0 # # # # Unless required by applicable law or agreed to in writing, software # # distributed under the License is distributed on an "AS IS" BASIS, # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # # limitations under the License. # ################################################################################ while [ -n "$1" ]; do # while loop starts case "$1" in -f) OVERRIDEYAML=$2 shift ;; -c) LIST_OF_COMPONENTS=$2 shift ;; *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c esac shift done if [ -z "$OVERRIDEYAML" ];then echo "****************************************************************************************************************" echo " ERROR " echo "****************************************************************************************************************" echo "RIC deployment without deployment recipe is currently disabled. Please specify an recipe with the -f option." echo "****************************************************************************************************************" exit 1 fi DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" COMMON_BLOCK=$(cat $OVERRIDEYAML | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}') NAMESPACE_BLOCK=$(cat $OVERRIDEYAML | awk '/^ namespace:/{getline; while ($0 ~ /^ .*|^ *$/) {print $0; if (getline == 0) {break}}}') NONRTRIC_NAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *nonrtric:/{print $2}') RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}') PARENT_CHART=$(cat $OVERRIDEYAML | awk '/^ *component:/{print $2}') COMPONENTS=${LIST_OF_COMPONENTS:-"controlpanel a1controller a1simulator policymanagementservice enrichmentservice nonrtric"} echo "Chart name- $PARENT_CHART" if ! kubectl get ns ${NONRTRIC_NAMESPACE:-nonrtric}> /dev/null 2>&1; then kubectl create ns ${NONRTRIC_NAMESPACE:-nonrtric} fi if ! kubectl get ns onap > /dev/null 2>&1; then kubectl create ns onap fi kubectl create configmap -n ${NONRTRIC_NAMESPACE:-nonrtric} nonrtric-recipe --from-file=recipe=$OVERRIDEYAML echo "Deploying NONRTRIC components [$COMPONENTS]" echo "Updating the Parent Chart [$PARENT_CHART]" helm dep up $DIR/../helm/$PARENT_CHART helm install $DIR/../helm/"${PARENT_CHART}" -f $OVERRIDEYAML --namespace "${NONRTRIC_NAMESPACE:-nonrtric}" --name "${RELEASE_PREFIX}"