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 "****************************************************************************************************************"
49 IS_HELM3=$(helm version -c --short|grep -e "^v3")
53 HELM_SEARCH_FLAG="repo"
57 HAS_RIC_COMMON_PACKAGE=$(helm search ${HELM_SEARCH_FLAG} local/ric-common | grep ric-common)
59 if [ -z "$HAS_RIC_COMMON_PACKAGE" ];then
60 echo "****************************************************************************************************************"
62 echo "****************************************************************************************************************"
63 echo "Can't locate the ric-common helm package in the local repo. Please make sure that it is properly installed."
64 echo "****************************************************************************************************************"
68 HAS_AUX_COMMON_PACKAGE=$(helm search ${HELM_SEARCH_FLAG} local/aux-common | grep aux-common)
70 if [ -z "$HAS_AUX_COMMON_PACKAGE" ];then
71 echo "****************************************************************************************************************"
73 echo "****************************************************************************************************************"
74 echo "Can't locate the aux-common helm package in the local repo. Please make sure that it is properly installed."
75 echo "****************************************************************************************************************"
81 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
83 COMMON_BLOCK=$(cat $OVERRIDEYAML | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
84 NAMESPACE_BLOCK=$(cat $OVERRIDEYAML | awk '/^ namespace:/{getline; while ($0 ~ /^ .*|^ *$/) {print $0; if (getline == 0) {break}}}')
85 AUXNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *aux:/{print $2}')
86 INFRANAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *infra:/{print $2}')
87 RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
88 COMPONENTS=${LIST_OF_COMPONENTS:-"infrastructure dashboard ves message-router mrsub mc-stack portal aaf"}
91 NODENAME=$(kubectl get node | awk 'NR>1{print $1}')
93 for f in $NODENAME; do
94 LABEL=$(kubectl describe node $f | grep "local-storage=enable")
95 if [ ! -z "$LABEL" ]; then
97 echo "Found lable \"local-storage=enable\" at node $f"
101 FOUND_STORAGECLASS=$(grep -w storageclass $OVERRIDEYAML)
104 if ! $LABELFOUND && [ -z "$FOUND_STORAGECLASS" ]; then
105 echo "***********************************************************************************************"
106 echo "* ERROR!!!!!!!!!!!!! *"
107 echo "***********************************************************************************************"
108 echo "* Nodes label \"local-storage=enable\" is not found in any of the cluster node. *"
109 echo "* Please pick a node and label it using the following command. *"
110 echo "* kubectl label --overwrite nodes <YOUR_NODE_NAME> local-storage=enable *"
111 echo "***********************************************************************************************"
117 if [ -z "$FOUND_STORAGECLASS" ] && $LABELFOUND; then
119 DATAPATH=$(cat $DIR/../helm/dashboard/values.yaml | grep datapath | awk '{ print $2}' )
122 if [ ! -z $OVERRIDEYAML ]; then
123 DATAPATHOVERRIDE=$(cat $OVERRIDEYAML | grep datapath | awk '{ print $2}' )
126 if [ ! -z "$DATAPATHOVERRIDE" ]; then
127 DATAPATH=$DATAPATHOVERRIDE
130 if [ ! -d "$DATAPATH" ]; then
131 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 ; }
134 echo "***********************************************************************************************"
135 echo "* WARNING!!!!!!!!!!!!! *"
136 echo "***********************************************************************************************"
137 echo "* Dashboard will use local storage. Please make sure that directory *"
139 echo "* contains the proper files. *"
140 echo "***********************************************************************************************"
146 for f in $NODENAME; do
147 LABEL=$(kubectl describe node $f | grep "portal-storage=enable")
148 if [ ! -z "$LABEL" ]; then
150 echo "Found lable \"portal-storage=enable\" at node $f"
154 if ! $LABELFOUND; then
155 echo "***********************************************************************************************"
156 echo "* ERROR!!!!!!!!!!!!! *"
157 echo "***********************************************************************************************"
158 echo "* Nodes label \"portal-storage=enable\" is not found in any of the cluster node. *"
159 echo "* Please pick a node and label it using the following command. i *"
160 echo "* kubectl label --overwrite nodes <YOUR_NODE_NAME> portal-storage=enable *"
161 echo "***********************************************************************************************"
168 if ! kubectl get ns ${AUXNAMESPACE:-ricaux}> /dev/null 2>&1; then
169 kubectl create ns ${AUXNAMESPACE:-ricaux}
171 if ! kubectl get ns ${INFRANAMESPACE:-ricinfra}> /dev/null 2>&1; then
172 kubectl create ns ${INFRANAMESPACE:-ricinfra}
174 if ! kubectl get ns onap > /dev/null 2>&1; then
175 kubectl create ns onap
181 echo Add cluster roles
182 cat >ricaux-role.yaml <<EOF
184 apiVersion: rbac.authorization.k8s.io/v1
187 name: ricaux-system-default
192 - apiGroups: ["batch"]
193 resources: ["jobs/status"]
197 apiVersion: rbac.authorization.k8s.io/v1
198 kind: ClusterRoleBinding
200 name: ricaux-system-default
202 apiGroup: rbac.authorization.k8s.io
204 name: ricaux-system-default
206 - kind: ServiceAccount
208 namespace: ${AUXNAMESPACE:-ricaux}
210 apiVersion: rbac.authorization.k8s.io/v1
213 name: onap-system-default
218 - apiGroups: ["apps"]
219 resources: ["replicasets/status"]
221 - apiGroups: ["batch"]
222 resources: ["jobs/status"]
224 - apiGroups: ["apps"]
225 resources: ["deployments", "statefulsets"]
229 apiVersion: rbac.authorization.k8s.io/v1
230 kind: ClusterRoleBinding
232 name: onap-system-default
234 apiGroup: rbac.authorization.k8s.io
236 name: onap-system-default
238 - kind: ServiceAccount
243 apiVersion: rbac.authorization.k8s.io/v1
246 name: ricaux-system-tiller
249 resources: ["deployments"]
250 verbs: ["get", "list", "create", "delete"]
251 - apiGroups: ["apiextensions.k8s.io"]
252 resources: ["customresourcedefinitions"]
253 verbs: ["get", "list", "create", "delete"]
254 - apiGroups: ["rbac.authorization.k8s.io"]
255 resources: ["clusterroles", "clusterrolebindings"]
256 verbs: ["get", "list", "create", "delete"]
258 resources: ["events"]
259 verbs: ["create", "patch"]
262 verbs: ["list", "watch", "get"]
263 - apiGroups: ["configuration.konghq.com"]
264 resources: ["kongconsumers"]
265 verbs: ["get", "list", "watch"]
266 - apiGroups: ["configuration.konghq.com"]
267 resources: ["kongcredentials"]
268 verbs: ["get", "list", "watch"]
269 - apiGroups: ["configuration.konghq.com"]
270 resources: ["kongingresses"]
271 verbs: ["get", "list", "watch"]
272 - apiGroups: ["configuration.konghq.com"]
273 resources: ["kongplugins"]
274 verbs: ["get", "list", "watch"]
275 - apiGroups: ["extensions"]
276 resources: ["ingresses/status"]
278 - apiGroups: ["networking.k8s.io"]
279 resources: ["ingresses/status"]
281 - apiGroups: ["networking.k8s.io"]
282 resources: ["ingresses"]
283 verbs: ["get", "list", "create", "delete", "watch"]
284 - apiGroups: ["danm.k8s.io"]
285 resources: ["clusternetworks"]
286 verbs: ["get", "list", "create", "delete"]
287 - apiGroups: ["storage.k8s.io"]
288 resources: ["storageclasses"]
289 verbs: ["get", "list", "create", "delete"]
291 resources: ["persistentvolumes"]
292 verbs: ["get", "list", "create", "delete"]
296 apiVersion: rbac.authorization.k8s.io/v1
297 kind: ClusterRoleBinding
299 name: ricaux-system-tiller
301 apiGroup: rbac.authorization.k8s.io
303 name: ricaux-system-tiller
305 - kind: ServiceAccount
307 namespace: kube-system
309 kubectl apply -f ricaux-role.yaml
312 kubectl create configmap -n ${AUXNAMESPACE:-ricaux} aux-recipe --from-file=recipe=$OVERRIDEYAML
316 echo "Clean up dockerdata-nfs directory"
317 rm -rf /dockerdata-nfs/*
320 echo "Deploying AUX components [$COMPONENTS]"
324 for component in $COMPONENTS; do
325 helm dep up $DIR/../helm/$component
327 # Handle helm2/helm3 arg
329 if [ -z $IS_HELM3 ]; then
335 NODENAME=$(kubectl get node | awk 'NR>1{print $1}')
337 for f in $NODENAME; do
338 LABEL=$(kubectl describe node $f | grep "aaf-storage=enable")
339 if [ ! -z "$LABEL" ]; then
341 echo "Found lable \"aaf-storage=enable\" at node $f"
345 if ! $LABELFOUND; then
346 echo "***********************************************************************************************"
347 echo "* ERROR!!!!!!!!!!!!! *"
348 echo "***********************************************************************************************"
349 echo "* Nodes label \"aaf-storage=enable\" is not found in any of the cluster node. *"
350 echo "* Please pick a node and label it using the following command. *"
351 echo "* kubectl label --overwrite nodes <YOUR_NODE_NAME> aaf-storage=enable *"
352 echo "***********************************************************************************************"
354 helm install -f $OVERRIDEYAML --namespace "onap" ${NAME_ARG} "${RELEASE_PREFIX}-$component" $DIR/../helm/$component
358 helm install -f $OVERRIDEYAML --namespace "${AUXNAMESPACE:-ricaux}" ${NAME_ARG} "${RELEASE_PREFIX}-$component" $DIR/../helm/$component