update pkill helm to each script
[rec.git] / workflows / ric_automation.sh
1 #!/bin/bash
2 #------------------------Pre-Modification----------------------------------------------------
3 mkdir RIC
4 cd RIC
5
6 #---------Clone the repo and perform the steps customize the deployment and values files------
7 git clone https://gerrit.o-ran-sc.org/r/it/dep
8 #run the localize script
9 cd /home/cloudadmin/RIC/dep
10 git checkout 189c974169043e89fa216df5ca638fb550e041e4
11 cat <<EOF >runric_env.sh
12
13 #!/bin/bash
14 ################################################################################
15 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
16 #   Copyright (c) 2019 Nokia.                                                  #
17 #                                                                              #
18 #   Licensed under the Apache License, Version 2.0 (the "License");            #
19 #   you may not use this file except in compliance with the License.           #
20 #   You may obtain a copy of the License at                                    #
21 #                                                                              #
22 #       http://www.apache.org/licenses/LICENSE-2.0                             #
23 #                                                                              #
24 #   Unless required by applicable law or agreed to in writing, software        #
25 #   distributed under the License is distributed on an "AS IS" BASIS,          #
26 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
27 #   See the License for the specific language governing permissions and        #
28 #   limitations under the License.                                             #
29 ################################################################################
30
31
32 # customize the following repo info to local infrastructure
33 export __RICENV_SET__='1'
34 export __RUNRICENV_GERRIT_HOST__='gerrit-o-ran-sc.org'
35 export __RUNRICENV_GERRIT_IP__='34.215.66.175'_
36
37 export __RUNRICENV_DOCKER_HOST__='rancodev'
38 export __RUNRICENV_DOCKER_IP__='127.0.0.1'
39 export __RUNRICENV_DOCKER_PORT__='5555'
40 export __RUNRICENV_DOCKER_USER__='docker'
41 export __RUNRICENV_DOCKER_PASS__='docker'
42
43 export __RUNRICENV_HELMREPO_HOST__='chart-repo.kube-system.svc.rec.io'
44 export __RUNRICENV_HELMREPO_PORT__='8088/charts'
45 export __RUNRICENV_HELMREPO_IP__='127.0.0.1'
46 export __RUNRICENV_HELMREPO_USER__='helm'
47 export __RUNRICENV_HELMREPO_PASS__='helm'
48 EOF
49
50 source runric_env.sh
51 ./localize.sh
52
53 cd generated/ricplt
54 deployment_files="$(find . -name deployment.yaml)"
55 for file in $deployment_files; do
56   sed -i '/restartPolicy/d' "$file"
57 done
58
59 #------------------Delete the nodeport and privileges lines----------------------------------------
60 sed -ri 's/^(\s*)(type\s*:\s*NodePort\s*$)/\1type: ClusterIP/' appmgr/charts/appmgr/values.yaml
61 sed -ri 's/^(\s*)(type\s*:\s*NodePort\s*$)/\1type: ClusterIP/' e2mgr/charts/e2mgr/values.yaml
62 deployment_files="$(find . -name deployment.yaml)"
63 for file in $deployment_files; do
64   sed -i '/privileged: true/d' "$file"
65 done
66
67 #------------------Edit the appmgr file including the path of the ca certificate-------------------
68 cp /etc/openssl/ca.pem preric/resources/helmrepo.crt
69 sed -i '/hostAliases:/,/system.svc.rec.io"/d' appmgr/charts/appmgr/templates/deployment.yaml
70
71 #-----------------Update tiller container name-----------------------------------------------------
72 sed -ri 's/^(\s*)("tiller-service"\s*:\s*"tiller-deploy"\s*$)/\1"tiller-service": "tiller"/' appmgr/charts/appmgr/values.yaml
73
74 #-----------------Change the repo location to rec.io----------------------------------------------
75 values_files="$(find . -name values.yaml)"
76 for file in $values_files; do
77   sed -i 's,rancodev:5555,registry.kube-system.svc.rec.io:5555/ric,g' "$file"
78 done
79
80 #-----------------Change the repo location to rec.io---------------------------------------------
81 requirements_files="$(find . -name requirements.yaml)"
82 for file in $requirements_files; do
83   sed -i 's,local,localric,g' "$file"
84 done
85
86 sed -i 's,rancodev:5555,rancodev,g' ./prepull.sh
87 sed -i 's/docker logout/#/' ./prepull.sh
88 sed -i 's/docker login/#/' ./prepull.sh
89
90 #!/bin/bash
91 #-----------------Installation--------------------------------------------------------------------
92 #--------------Reloading docker images-----------------------------------------------------------
93 echo "docker" | sh ./prepull.sh
94
95 #retag scripts
96 for i in  \
97 "xapp-manager:latest" \
98 "e2mgr:1.0.0" \
99 "e2:1.0.0"  \
100 "rtmgr:0.0.2"  \
101 "redis-standalone:latest"
102 do
103 echo $i
104 docker tag  rancodev/${i} registry.kube-system.svc.rec.io:5555/ric/${i}
105 docker push  registry.kube-system.svc.rec.io:5555/ric/${i}
106 done
107
108 #-------------create ricplatform namespace------------------------------------------------------
109 kubectl create namespace ricplatform
110
111 #create ricplatform danmnet
112 cat <<!   | kubectl apply -f -
113 apiVersion: danm.k8s.io/v1
114 kind: DanmNet
115 metadata:
116   name: default
117   namespace: ricplatform
118 spec:
119   NetworkID: flannel
120   NetworkType: flannel
121 !
122
123 #------------run ric_install script-----------------------------------------------------------
124 sed -i 's,http://127.0.0.1:8879,http://127.0.0.1:8879/charts,g' "ric_install.sh"
125 sed -i 's,local,localric,g' "ric_install.sh"
126
127 bash -x ./ric_install.sh
128 #--------------kill helm---------------------------------------------------------------------
129 pkill helm
130 #-------------checking the output-------------------------------------------------------------
131 command="$(kubectl get po --no-headers --namespace=ricplatform --field-selector status.phase!=Running 2> /dev/null)"
132 if [[ $command != "" ]]; then
133   exit 1
134 fi
135
136