2 #############################################################################
4 # Copyright © 2018 Amdocs, Bell.
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 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 #############################################################################
19 # https://wiki.onap.org/display/DW/ONAP+on+Kubernetes
20 # source from https://jira.onap.org/browse/OOM-715, 716, 711
28 ./cd.sh -b amsterdam -e onap (will rerun onap in the onap namespace, no new repo, no deletion of existing repo, no sdnc workaround, no onap removal at the end
29 ./cd.sh -b master -e onap -c true -d true -w true -r true (run as cd server, new oom, delete prev oom, run workarounds, clean onap at the end of the script
30 ./cd.sh -b master -e onap -c true -d false -w true -r false (standard new server/dev environment - use this as the default)
33 -b [branch] : branch = master/beijing or amsterdam (required)
34 -e [environment] : use the default (onap)
35 -c [true|false] : FLAG clone new oom repo (default: true)
36 -d [true|false] : FLAG delete prev oom - (cd build) (default: false)
37 -w [true|false] : FLAG apply workarounds IE: sdnc (default: true)
38 -r [true|false] : FLAG remove oom at end of script - for use by CD only (default: false)
45 echo "running with: -b $BRANCH -e $ENVIRON -c $CLONE_NEW_OOM -d $DELETE_PREV_OOM -w $APPLY_WORKAROUNDS -r $REMOVE_OOM_AT_END"
46 echo "provide onap-parameters.yaml(amsterdam) or values.yaml(master) and aai-cloud-region-put.json"
48 # fix virtual memory for onap-log:elasticsearch under Rancher 1.6.11 - OOM-431
49 sudo sysctl -w vm.max_map_count=262144
50 if [[ "$DELETE_PREV_OOM" != false ]]; then
51 echo "remove existing oom"
52 # master/beijing only - not amsterdam
53 if [ "$BRANCH" == "amsterdam" ]; then
54 oom/kubernetes/oneclick/deleteAll.bash -n $ENVIRON
56 # workaround for secondary orchestration in dcae
57 kubectl delete namespace $ENVIRON
58 echo "sleep for 4 min to allow the delete to finish pod terminations before trying a helm delete"
60 sudo helm delete --purge $ENVIRON
65 DELETED=$(kubectl get pods --all-namespaces -a | -E '0/|1/2' | wc -l)
66 echo "verify deletion is finished."
67 while [ $(kubectl get pods --all-namespaces | grep -E '0/|1/2' | wc -l) -gt 0 ]; do
69 echo "waiting for deletions to complete"
71 # wait for 0/1 before deleting
72 echo "sleeping 30 sec"
73 # delete potential hanging clustered pods
74 #kubectl delete pod $ENVIRON-aaf-sms-vault-0 -n $ENVIRON --grace-period=0 --force
75 # specific to when there is no helm release
76 kubectl delete pv --all
77 kubectl delete pvc --all
78 kubectl delete secrets --all
79 kubectl delete clusterrolebinding --all
81 # keep jenkins 120 sec timeout happy with echos
83 echo "List of ONAP Modules - look for terminating pods"
84 LIST_ALL=$(kubectl get pods --all-namespaces --show-all -o wide )
87 # for use by continuous deployment only
88 echo " deleting /dockerdata-nfs"
89 sudo chmod -R 777 /dockerdata-nfs/onap
90 sudo chmod -R 777 /dockerdata-nfs/dev
91 rm -rf /dockerdata-nfs/onap
92 rm -rf /dockerdata-nfs/dev
94 # for use by continuous deployment only
95 if [[ "$CLONE_NEW_OOM" != false ]]; then
98 git clone -b $BRANCH http://gerrit.onap.org/r/oom
99 # https://wiki.onap.org/display/DW/OOM+Helm+%28un%29Deploy+plugins
100 sudo cp -R ~/oom/kubernetes/helm/plugins/ ~/.helm
103 if [ "$BRANCH" == "amsterdam" ]; then
104 echo "start config pod"
105 # still need to source docker variables
106 source oom/kubernetes/oneclick/setenv.bash
107 #echo "source setenv override"
108 echo "moving onap-parameters.yaml to oom/kubernetes/config"
109 cp onap-parameters.yaml oom/kubernetes/config
110 cd oom/kubernetes/config
111 ./createConfig.sh -n $ENVIRON
113 echo "verify onap-config is 0/1 not 1/1 - as in completed - an error pod - means you are missing onap-parameters.yaml or values are not set in it."
114 while [ $(kubectl get pods -n onap -a | grep config | grep 0/1 | grep Completed | wc -l) -eq 0 ]; do
116 echo "waiting for config pod to complete"
119 echo "moving values.yaml to oom/kubernetes/"
120 #sudo cp values.yaml oom/kubernetes/onap
123 # usually the prepull takes up to 25-300 min - however hourly builds will finish the docker pulls before the config pod is finished
124 #echo "pre pull docker images - 35+ min"
125 #wget https://jira.onap.org/secure/attachment/11261/prepull_docker.sh
126 #chmod 777 prepull_docker.sh
128 echo "start onap pods"
129 if [ "$BRANCH" == "amsterdam" ]; then
130 cd oom/kubernetes/oneclick
131 ./createAll.bash -n $ENVIRON
138 #sudo helm install local/onap -n onap --namespace $ENVIRON
139 sudo helm deploy onap local/onap --namespace $ENVIRON
143 echo "wait for all pods up for 15-80 min"
145 MAX_WAIT_PERIODS=480 # 120 MIN
148 while [ $(kubectl get pods --all-namespaces | grep -E '0/|1/2' | wc -l) -gt $FAILED_PODS_LIMIT ]; do
149 PENDING=$(kubectl get pods --all-namespaces | grep -E '0/|1/2' | wc -l)
150 PENDING_PODS=$PENDING
152 LIST_PENDING=$(kubectl get pods --all-namespaces -o wide | grep -E '0/|1/2' )
153 echo "${LIST_PENDING}"
154 echo "${PENDING} pending > ${FAILED_PODS_LIMIT} at the ${COUNTER}th 15 sec interval"
156 COUNTER=$((COUNTER + 1 ))
157 MAX_WAIT_PERIODS=$((MAX_WAIT_PERIODS - 1))
158 if [ "$MAX_WAIT_PERIODS" -eq 0 ]; then
159 FAILED_PODS_LIMIT=800
163 echo "report on non-running containers"
164 PENDING=$(kubectl get pods --all-namespaces | grep -E '0/|1/2')
165 PENDING_COUNT=$(kubectl get pods --all-namespaces | grep -E '0/|1/2' | wc -l)
166 PENDING_COUNT_AAI=$(kubectl get pods -n $ENVIRON | grep aai- | grep -E '0/|1/2' | wc -l)
167 if [ "$PENDING_COUNT_AAI" -gt 0 ]; then
168 echo "down-aai=${PENDING_COUNT_AAI}"
171 # todo don't stop if aai is down
172 PENDING_COUNT_APPC=$(kubectl get pods -n $ENVIRON | grep appc- | grep -E '0/|1/2' | wc -l)
173 if [ "$PENDING_COUNT_APPC" -gt 0 ]; then
174 echo "down-appc=${PENDING_COUNT_APPC}"
176 PENDING_COUNT_MR=$(kubectl get pods -n $ENVIRON | grep message-router- | grep -E '0/|1/2' | wc -l)
177 if [ "$PENDING_COUNT_MR" -gt 0 ]; then
178 echo "down-mr=${PENDING_COUNT_MR}"
180 PENDING_COUNT_SO=$(kubectl get pods -n $ENVIRON | grep so- | grep -E '0/|1/2' | wc -l)
181 if [ "$PENDING_COUNT_SO" -gt 0 ]; then
182 echo "down-so=${PENDING_COUNT_SO}"
184 PENDING_COUNT_POLICY=$(kubectl get pods -n $ENVIRON | grep policy- | grep -E '0/|1/2' | wc -l)
185 if [ "$PENDING_COUNT_POLICY" -gt 0 ]; then
186 echo "down-policy=${PENDING_COUNT_POLICY}"
188 PENDING_COUNT_PORTAL=$(kubectl get pods -n $ENVIRON | grep portal- | grep -E '0/|1/2' | wc -l)
189 if [ "$PENDING_COUNT_PORTAL" -gt 0 ]; then
190 echo "down-portal=${PENDING_COUNT_PORTAL}"
192 PENDING_COUNT_LOG=$(kubectl get pods -n $ENVIRON | grep log- | grep -E '0/|1/2' | wc -l)
193 if [ "$PENDING_COUNT_LOG" -gt 0 ]; then
194 echo "down-log=${PENDING_COUNT_LOG}"
196 PENDING_COUNT_ROBOT=$(kubectl get pods -n $ENVIRON | grep robot- | grep -E '0/|1/2' | wc -l)
197 if [ "$PENDING_COUNT_ROBOT" -gt 0 ]; then
198 echo "down-robot=${PENDING_COUNT_ROBOT}"
200 PENDING_COUNT_SDC=$(kubectl get pods -n $ENVIRON | grep sdc- | grep -E '0/|1/2' | wc -l)
201 if [ "$PENDING_COUNT_SDC" -gt 0 ]; then
202 echo "down-sdc=${PENDING_COUNT_SDC}"
204 PENDING_COUNT_SDNC=$(kubectl get pods -n $ENVIRON | grep sdnc- | grep -E '0/|1/2' | wc -l)
205 if [ "$PENDING_COUNT_SDNC" -gt 0 ]; then
206 echo "down-sdnc=${PENDING_COUNT_SDNC}"
208 PENDING_COUNT_VID=$(kubectl get pods -n $ENVIRON | grep vid- | grep -E '0/|1/2' | wc -l)
209 if [ "$PENDING_COUNT_VID" -gt 0 ]; then
210 echo "down-vid=${PENDING_COUNT_VID}"
213 PENDING_COUNT_AAF=$(kubectl get pods -n $ENVIRON | grep aaf- | grep -E '0/|1/2' | wc -l)
214 if [ "$PENDING_COUNT_AAF" -gt 0 ]; then
215 echo "down-aaf=${PENDING_COUNT_AAF}"
217 PENDING_COUNT_CONSUL=$(kubectl get pods -n $ENVIRON | grep consul- | grep -E '0/|1/2' | wc -l)
218 if [ "$PENDING_COUNT_CONSUL" -gt 0 ]; then
219 echo "down-consul=${PENDING_COUNT_CONSUL}"
221 PENDING_COUNT_MSB=$(kubectl get pods -n $ENVIRON | grep msb- | grep -E '0/|1/2' | wc -l)
222 if [ "$PENDING_COUNT_MSB" -gt 0 ]; then
223 echo "down-msb=${PENDING_COUNT_MSB}"
225 PENDING_COUNT_DCAE=$(kubectl get pods -n $ENVIRON | grep dcaegen2- | grep -E '0/|1/2' | wc -l)
226 if [ "$PENDING_COUNT_DCAE" -gt 0 ]; then
227 echo "down-dcae=${PENDING_COUNT_DCAE}"
229 PENDING_COUNT_CLI=$(kubectl get pods -n $ENVIRON | grep cli- | grep -E '0/|1/2' | wc -l)
230 if [ "$PENDING_COUNT_CLI" -gt 0 ]; then
231 echo "down-cli=${PENDING_COUNT_CLI}"
233 PENDING_COUNT_MULTICLOUD=$(kubectl get pods -n $ENVIRON | grep multicloud- | grep -E '0/|1/2' | wc -l)
234 if [ "$PENDING_COUNT_MULTICLOUD" -gt 0 ]; then
235 echo "down-multicloud=${PENDING_COUNT_MULTICLOUD}"
237 PENDING_COUNT_CLAMP=$(kubectl get pods -n $ENVIRON | grep clamp- | grep -E '0/|1/2' | wc -l)
238 if [ "$PENDING_COUNT_CLAMP" -gt 0 ]; then
239 echo "down-clamp=${PENDING_COUNT_CLAMP}"
241 PENDING_COUNT_VNFSDK=$(kubectl get pods -n $ENVIRON | grep vnfsdk- | grep -E '0/|1/2' | wc -l)
242 if [ "$PENDING_COUNT_VNFSDK" -gt 0 ]; then
243 echo "down-vnfsdk=${PENDING_COUNT_VNFSDK}"
245 PENDING_COUNT_UUI=$(kubectl get pods -n $ENVIRON | grep uui- | grep -E '0/|1/2' | wc -l)
246 if [ "$PENDING_COUNT_UUI" -gt 0 ]; then
247 echo "down-uui=${PENDING_COUNT_UUI}"
249 PENDING_COUNT_VFC=$(kubectl get pods -n $ENVIRON | grep vfc- | grep -E '0/|1/2' | wc -l)
250 if [ "$PENDING_COUNT_VFC" -gt 0 ]; then
251 echo "down-vfc=${PENDING_COUNT_VFC}"
253 PENDING_COUNT_KUBE2MSB=$(kubectl get pods -n $ENVIRON | grep kube2msb- | grep -E '0/|1/2' | wc -l)
254 if [ "$PENDING_COUNT_KUBE2MSB" -gt 0 ]; then
255 echo "down-kube2msb=${PENDING_COUNT_KUBE2MSB}"
257 echo "pending containers=${PENDING_COUNT}"
260 echo "check filebeat 2/2 count for ELK stack logging consumption"
261 FILEBEAT=$(kubectl get pods --all-namespaces -a | grep 2/)
263 echo "sleep 5 min - to allow rest frameworks to finish"
265 echo "List of ONAP Modules"
266 LIST_ALL=$(kubectl get pods --all-namespaces -a --show-all )
268 echo "run healthcheck 2 times to warm caches and frameworks so rest endpoints report properly - see OOM-447"
270 echo "curl with aai cert to cloud-region PUT"
272 curl -X PUT https://127.0.0.1:30233/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne --data "@aai-cloud-region-put.json" -H "authorization: Basic TW9kZWxMb2FkZXI6TW9kZWxMb2FkZXI=" -H "X-TransactionId:jimmy-postman" -H "X-FromAppId:AAI" -H "Content-Type:application/json" -H "Accept:application/json" --cacert aaiapisimpledemoopenecomporg_20171003.crt -k
274 echo "get the cloud region back"
275 curl -X GET https://127.0.0.1:30233/aai/v11/cloud-infrastructure/cloud-regions/ -H "authorization: Basic TW9kZWxMb2FkZXI6TW9kZWxMb2FkZXI=" -H "X-TransactionId:jimmy-postman" -H "X-FromAppId:AAI" -H "Content-Type:application/json" -H "Accept:application/json" --cacert aaiapisimpledemoopenecomporg_20171003.crt -k
277 # OOM-484 - robot scripts moved
278 cd oom/kubernetes/robot
279 echo "run healthcheck prep 1"
280 # OOM-722 adds namespace parameter
281 if [ "$BRANCH" == "amsterdam" ]; then
282 ./ete-k8s.sh health > ~/health1.out
284 ./ete-k8s.sh $ENVIRON health > ~/health1.out
288 echo "run healthcheck prep 2"
289 if [ "$BRANCH" == "amsterdam" ]; then
290 ./ete-k8s.sh health > ~/health2.out
292 ./ete-k8s.sh $ENVIRON health > ~/health2.out
294 echo "run healthcheck for real - wait a further 5 min"
296 if [ "$BRANCH" == "amsterdam" ]; then
299 ./ete-k8s.sh $ENVIRON health
301 echo "run partial vFW"
302 # sudo chmod 777 /dockerdata-nfs/onap
303 # if [ "$BRANCH" == "amsterdam" ]; then
304 # ./demo-k8s.sh init_robot
306 # ./demo-k8s.sh $ENVIRON init
308 # if [ "$BRANCH" == "amsterdam" ]; then
311 # ./demo-k8s.sh $ENVIRON init
313 echo "report results"
322 APPLY_WORKAROUNDS=true
323 DELETE_PREV_OOM=false
324 REMOVE_OOM_AT_END=false
327 while getopts ":u:b:e:c:d:w:r" PARAM; do
340 CLONE_NEW_OOM=${OPTARG}
343 DELETE_PREV_OOM=${OPTARG}
346 APPLY_WORKAROUNDS=${OPTARG}
349 REMOVE_OOM_AT_END=${OPTARG}
358 if [[ -z $BRANCH ]]; then
363 deploy_onap $BRANCH $ENVIRON $CLONE_NEW_OOM $DELETE_PREV_OOM $APPLY_WORKAROUNDS $REMOVE_OOM_AT_END
365 printf "**** Done ****\n"