Add one-click deployment scripts for deploying INFRA PLT and AUX
[it/dep.git] / bin / deploy-ric-infra
1 #!/bin/bash
2 ################################################################################
3 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
4 #   Copyright (c) 2019 Nokia.                                                  #
5 #                                                                              #
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                                    #
9 #                                                                              #
10 #       http://www.apache.org/licenses/LICENSE-2.0                             #
11 #                                                                              #
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 ################################################################################
18
19 # This script deploys RIC platform components automatically
20
21 OVERRIDEYAML=$1
22
23 if [ -z "$OVERRIDEYAML" ];then
24 echo "****************************************************************************************************************"
25 echo "                                                     WARNING                                                    "
26 echo "****************************************************************************************************************"
27 echo "Preparing the clusters for RIC deployment without deployment recipe. Default configurations are used."
28 echo "****************************************************************************************************************"
29
30
31 fi
32
33
34 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
35
36 source $ROOT_DIR/../etc/ric.conf
37 source $ROOT_DIR/../etc/ric-infra.conf
38
39
40 export RICINFRA_RELEASE_NAME=$helm_release_name
41
42 export RICPLT_NAMESPACE=$plt_namespace
43 export RICXAPP_NAMESPACE=$xapp_namespace
44 export RICAUX_NAMESPACE=$aux_namespace
45 export RICINFRA_NAMESPACE=$infra_namespace
46
47
48 if [ ! -z $OVERRIDEYAML ]; then
49         DEPLOY_K8S_FROM_OVERRIDE=$(cat $OVERRIDEYAML | grep deployK8S: | awk '{print $2}')
50         USE_LOCAL_HELM_REPO_FROM_OVERRIDE=$(cat $OVERRIDEYAML | grep useLocalHelmRepo: | awk '{print $2}')
51         USE_LOCAL_DOCKER_REGISTRY_FROM_OVERRIDE=$(cat $OVERRIDEYAML | grep useLocalDockerRegistry: | awk '{print $2}')
52         DEPLOY_K8S_MONITORING_FROM_OVERRIDE=$(cat $OVERRIDEYAML | grep deployK8SMonitoringStake: | awk '{print $2}')
53 fi
54
55 if [ -z $DEPLOY_K8S_FROM_OVERRIDE ]; then
56         export DEPLOY_K8S=$deployK8S
57 else
58         export DEPLOY_K8S=$DEPLOY_K8S_FROM_OVERRIDE
59 fi
60
61 if [ -z $USE_LOCAL_HELM_REPO_FROM_OVERRIDE ]; then
62         export USE_LOCAL_HELM_REPO=$useLocalHelmRepo
63 else
64         export USE_LOCAL_HELM_REPO=$USE_LOCAL_HELM_REPO_FROM_OVERRIDE
65 fi
66
67 if [ -z $USE_LOCAL_DOCKER_REGISTRY_FROM_OVERRIDE ]; then
68         export USE_LOCAL_DOCKER_REGISTRY=$useLocalDockerRegistry
69 else
70         export USE_LOCAL_DOCKER_REGISTRY=$USE_LOCAL_DOCKER_REGISTRY_FROM_OVERRIDE
71 fi
72
73 if [ -z $DEPLOY_K8S_MONITORING_FROM_OVERRIDE ]; then
74         export DEPLOY_K8S_MONITORING=$deployK8S
75 else
76         export DEPLOY_K8S_MONITORING=$DEPLOY_K8S_MONITORING_FROM_OVERRIDE
77 fi
78
79
80 if ! $USE_LOCAL_HELM_REPO; then
81         echo "****************************************************************************************************************"
82         echo "                                                     WARNING                                                    "
83         echo "****************************************************************************************************************"
84         echo "RIC will use an external helm repository. Please make sure that the certificate is included in the recipe file."
85         echo "****************************************************************************************************************"
86 fi
87
88
89 if $USE_LOCAL_DOCKER_REGISTRY; then
90         echo "****************************************************************************************************************"
91         echo "                                                     WARNING                                                    "
92         echo "****************************************************************************************************************"
93         echo "RIC will use an internal docker registry. You need to manually include the certificate to all servers in the cluster."
94         echo "****************************************************************************************************************"
95 fi
96
97
98
99 for component in $ROOT_DIR/../ric-infra/*/; do
100         component_name=$(echo $component | awk '{n=split($0, temp,"/"); print temp[n-1];}')
101
102         case "$component_name" in
103                 00-Kubernetes)
104                         if $DEPLOY_K8S; then
105                                 . $component/bin/install $OVERRIDEYAM
106                         fi
107                 ;;
108                 10-Nexus)
109                         if $USE_LOCAL_DOCKER_REGISTRY; then
110                                 . $component/bin/install $OVERRIDEYAM
111                         fi
112                 ;;
113                 15-Chartmuseum)
114                         if $USE_LOCAL_HELM_REPO; then
115                                 . $component/bin/install $OVERRIDEYAM
116                         fi
117                 ;;
118                 20-Monitoring)
119                         if $DEPLOY_K8S_MONITORING; then
120                                 . $component/bin/install $OVERRIDEYAM
121                         fi
122                 ;;
123                 *)
124                     . $component/bin/install $OVERRIDEYAM
125         
126         esac
127 done
128
129
130