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 HAS_RIC_COMMON_PACKAGE=$(helm search local/ric-common | grep ric-common)
51 if [ -z "$HAS_RIC_COMMON_PACKAGE" ];then
52 echo "****************************************************************************************************************"
54 echo "****************************************************************************************************************"
55 echo "Can't locate the ric-common helm package in the local repo. Please make sure that it is properly installed."
56 echo "****************************************************************************************************************"
60 HAS_AUX_COMMON_PACKAGE=$(helm search local/aux-common | grep aux-common)
62 if [ -z "$HAS_AUX_COMMON_PACKAGE" ];then
63 echo "****************************************************************************************************************"
65 echo "****************************************************************************************************************"
66 echo "Can't locate the aux-common helm package in the local repo. Please make sure that it is properly installed."
67 echo "****************************************************************************************************************"
73 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
75 COMMON_BLOCK=$(cat $OVERRIDEYAML | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}')
76 NAMESPACE_BLOCK=$(cat $OVERRIDEYAML | awk '/^ namespace:/{getline; while ($0 ~ /^ .*|^ *$/) {print $0; if (getline == 0) {break}}}')
77 AUXNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *aux:/{print $2}')
78 INFRANAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *infra:/{print $2}')
79 RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
80 COMPONENTS=${LIST_OF_COMPONENTS:-"infrastructure dashboard ves message-router mrsub mc-stack portal aaf"}
83 NODENAME=$(kubectl get node | awk 'NR>1{print $1}')
85 for f in $NODENAME; do
86 LABEL=$(kubectl describe node $f | grep "local-storage=enable")
87 if [ ! -z "$LABEL" ]; then
89 echo "Found lable \"local-storage=enable\" at node $f"
93 FOUND_STORAGECLASS=$(grep -w storageclass $OVERRIDEYAML)
96 if ! $LABELFOUND && [ -z "$FOUND_STORAGECLASS" ]; then
97 echo "***********************************************************************************************"
98 echo "* ERROR!!!!!!!!!!!!! *"
99 echo "***********************************************************************************************"
100 echo "* Nodes label \"local-storage=enable\" is not found in any of the cluster node. *"
101 echo "* Please pick a node and label it using the following command. *"
102 echo "* kubectl label --overwrite nodes <YOUR_NODE_NAME> local-storage=enable *"
103 echo "***********************************************************************************************"
109 if [ -z "$FOUND_STORAGECLASS" ] && $LABELFOUND; then
111 DATAPATH=$(cat $DIR/../helm/dashboard/values.yaml | grep datapath | awk '{ print $2}' )
114 if [ ! -z $OVERRIDEYAML ]; then
115 DATAPATHOVERRIDE=$(cat $OVERRIDEYAML | grep datapath | awk '{ print $2}' )
118 if [ ! -z "$DATAPATHOVERRIDE" ]; then
119 DATAPATH=$DATAPATHOVERRIDE
122 if [ ! -d "$DATAPATH" ]; then
123 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 ; }
126 echo "***********************************************************************************************"
127 echo "* WARNING!!!!!!!!!!!!! *"
128 echo "***********************************************************************************************"
129 echo "* Dashboard will use local storage. Please make sure that directory *"
131 echo "* contains the proper files. *"
132 echo "***********************************************************************************************"
138 for f in $NODENAME; do
139 LABEL=$(kubectl describe node $f | grep "portal-storage=enable")
140 if [ ! -z "$LABEL" ]; then
142 echo "Found lable \"portal-storage=enable\" at node $f"
146 if ! $LABELFOUND; then
147 echo "***********************************************************************************************"
148 echo "* ERROR!!!!!!!!!!!!! *"
149 echo "***********************************************************************************************"
150 echo "* Nodes label \"portal-storage=enable\" is not found in any of the cluster node. *"
151 echo "* Please pick a node and label it using the following command. i *"
152 echo "* kubectl label --overwrite nodes <YOUR_NODE_NAME> portal-storage=enable *"
153 echo "***********************************************************************************************"
160 if ! kubectl get ns ${AUXNAMESPACE:-ricaux}> /dev/null 2>&1; then
161 kubectl create ns ${AUXNAMESPACE:-ricaux}
163 if ! kubectl get ns ${INFRANAMESPACE:-ricinfra}> /dev/null 2>&1; then
164 kubectl create ns ${INFRANAMESPACE:-ricinfra}
166 if ! kubectl get ns onap > /dev/null 2>&1; then
167 kubectl create ns onap
173 echo Add cluster roles
174 cat >ricaux-role.yaml <<EOF
176 apiVersion: rbac.authorization.k8s.io/v1
179 name: ricaux-system-default
184 - apiGroups: ["batch"]
185 resources: ["jobs/status"]
189 apiVersion: rbac.authorization.k8s.io/v1
190 kind: ClusterRoleBinding
192 name: ricaux-system-default
194 apiGroup: rbac.authorization.k8s.io
196 name: ricaux-system-default
198 - kind: ServiceAccount
200 namespace: ${AUXNAMESPACE:-ricaux}
202 apiVersion: rbac.authorization.k8s.io/v1
205 name: onap-system-default
210 - apiGroups: ["apps"]
211 resources: ["replicasets/status"]
213 - apiGroups: ["batch"]
214 resources: ["jobs/status"]
216 - apiGroups: ["apps"]
217 resources: ["deployments", "statefulsets"]
221 apiVersion: rbac.authorization.k8s.io/v1
222 kind: ClusterRoleBinding
224 name: onap-system-default
226 apiGroup: rbac.authorization.k8s.io
228 name: onap-system-default
230 - kind: ServiceAccount
235 apiVersion: rbac.authorization.k8s.io/v1
238 name: ricaux-system-tiller
241 resources: ["deployments"]
242 verbs: ["get", "list", "create", "delete"]
243 - apiGroups: ["apiextensions.k8s.io"]
244 resources: ["customresourcedefinitions"]
245 verbs: ["get", "list", "create", "delete"]
246 - apiGroups: ["rbac.authorization.k8s.io"]
247 resources: ["clusterroles", "clusterrolebindings"]
248 verbs: ["get", "list", "create", "delete"]
250 resources: ["events"]
251 verbs: ["create", "patch"]
254 verbs: ["list", "watch", "get"]
255 - apiGroups: ["configuration.konghq.com"]
256 resources: ["kongconsumers"]
257 verbs: ["get", "list", "watch"]
258 - apiGroups: ["configuration.konghq.com"]
259 resources: ["kongcredentials"]
260 verbs: ["get", "list", "watch"]
261 - apiGroups: ["configuration.konghq.com"]
262 resources: ["kongingresses"]
263 verbs: ["get", "list", "watch"]
264 - apiGroups: ["configuration.konghq.com"]
265 resources: ["kongplugins"]
266 verbs: ["get", "list", "watch"]
267 - apiGroups: ["extensions"]
268 resources: ["ingresses/status"]
270 - apiGroups: ["networking.k8s.io"]
271 resources: ["ingresses/status"]
273 - apiGroups: ["networking.k8s.io"]
274 resources: ["ingresses"]
275 verbs: ["get", "list", "create", "delete", "watch"]
276 - apiGroups: ["danm.k8s.io"]
277 resources: ["clusternetworks"]
278 verbs: ["get", "list", "create", "delete"]
279 - apiGroups: ["storage.k8s.io"]
280 resources: ["storageclasses"]
281 verbs: ["get", "list", "create", "delete"]
283 resources: ["persistentvolumes"]
284 verbs: ["get", "list", "create", "delete"]
288 apiVersion: rbac.authorization.k8s.io/v1
289 kind: ClusterRoleBinding
291 name: ricaux-system-tiller
293 apiGroup: rbac.authorization.k8s.io
295 name: ricaux-system-tiller
297 - kind: ServiceAccount
299 namespace: kube-system
301 kubectl apply -f ricaux-role.yaml
304 kubectl create configmap -n ${AUXNAMESPACE:-ricaux} aux-recipe --from-file=recipe=$OVERRIDEYAML
308 echo "Clean up dockerdata-nfs directory"
309 rm -rf /dockerdata-nfs/*
312 echo "Deploying AUX components [$COMPONENTS]"
316 for component in $COMPONENTS; do
317 helm dep up $DIR/../helm/$component
320 NODENAME=$(kubectl get node | awk 'NR>1{print $1}')
322 for f in $NODENAME; do
323 LABEL=$(kubectl describe node $f | grep "aaf-storage=enable")
324 if [ ! -z "$LABEL" ]; then
326 echo "Found lable \"aaf-storage=enable\" at node $f"
330 if ! $LABELFOUND; then
331 echo "***********************************************************************************************"
332 echo "* ERROR!!!!!!!!!!!!! *"
333 echo "***********************************************************************************************"
334 echo "* Nodes label \"aaf-storage=enable\" is not found in any of the cluster node. *"
335 echo "* Please pick a node and label it using the following command. *"
336 echo "* kubectl label --overwrite nodes <YOUR_NODE_NAME> aaf-storage=enable *"
337 echo "***********************************************************************************************"
339 helm install -f $OVERRIDEYAML --namespace "onap" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component
343 helm install -f $OVERRIDEYAML --namespace "${AUXNAMESPACE:-ricaux}" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component