enable kubectl del --force for rogue pods
[logging-analytics.git] / deploy / cd.sh
1 #!/bin/bash
2 #############################################################################
3 #
4 # Copyright © 2019 Amdocs.
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 #        http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16 #
17 #############################################################################
18 # v20190115
19 # https://wiki.onap.org/display/DW/ONAP+on+Kubernetes
20 # source from https://jira.onap.org/browse/OOM-320, 326, 321, 898, 925, 914
21 # Michael O'Brien
22 #
23
24 usage() {
25   cat <<EOF
26 Usage: $0 [PARAMs]
27 example 
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 -s 500 -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 3.0.0-ONAP -e onap -p true -n nexus3.onap.org:10001 -f true -s 600 -c true -d false -w true -r false (standard new server/dev environment - use this as the default)
31 provide a dev0.yaml/dev1.yaml override set (0=platform, 1=rest of pods) - copy from https://git.onap.org/oom/tree/kubernetes/onap/resources/environments/dev.yaml
32  note: the managed deploy where -f is true - deploys all of ONAP - for a subset driven by the enabled flags in the dev yaml - use -f false - as the --set enabled flags override in the prior case
33 -u                  : Display usage
34 -b [branch]         : branch = master/beijing or amsterdam (required)
35 -e [environment]    : use the default (onap)
36 -p [true|false]     : docker prepull (default false)
37 -n [nexus3 url:port]: nexus3.onap.org:10001 or proxy - used in prepull
38 -f [true|false]     : managed deploy - time sequenced - defaults to a full deploy
39 -s [seconds]        : delay between base and rest of onap dual-deployments based on dev0 and dev1.yaml
40 -c [true|false]     : FLAG clone new oom repo (default: true)
41 -d [true|false]     : FLAG delete prev oom - (cd build) (default: false)
42 -w [true|false]     : FLAG apply workarounds  IE: sdnc (default: true)
43 -r [true|false]     : FLAG remove oom at end of script - for use by CD only (default: false)
44 EOF
45 }
46
47 wait_for_pod() {
48       local RUNNING_PODS_LIMIT=$2
49       local MAX_WAIT_PERIODS=140 # 35 MIN
50       local COUNTER=1
51       local PENDING_PODS=0
52       local TARGET_POD_PREFIX=$1
53       local PENDING=0
54       while [  $PENDING -lt $RUNNING_PODS_LIMIT  ]; do
55         PENDING=$(kubectl get pods --all-namespaces | grep $TARGET_POD_PREFIX | grep -E '1/1|2/2|1/3|2/3' | wc -l)
56         PENDING_PODS=$PENDING
57         sleep 15
58         LIST_PENDING=$(kubectl get pods --all-namespaces -o wide | grep $TARGET_POD_PREFIX | grep -E '1/1|2/2|1/3|2/3' )
59         echo "${PENDING} running < ${RUNNING_PODS_LIMIT} at the ${COUNTER}th 15 sec interval for $TARGET_POD_PREFIX"
60         COUNTER=$((COUNTER + 1 ))
61         MAX_WAIT_PERIODS=$((MAX_WAIT_PERIODS - 1))
62         if [ "$MAX_WAIT_PERIODS" -eq 0 ]; then
63           PENDING=800
64         fi
65      done
66      dt="$(date +"%T")"
67      echo "$dt: ${PENDING} pods are up (1/1|2/2|3/3) for $TARGET_POD_PREFIX at the ${COUNTER}th 15 sec interval"
68      echo "deployments: note order: helm list"
69      sudo helm list
70      kubectl get pods --all-namespaces -o wide
71 }
72
73 deploy_onap() {
74   echo "$(date)"
75   echo "running with: -b $BRANCH -e $ENVIRON -p $DOCKER_PREPULL -n $NEXUS3_AND_PORT -f $FULL_MANAGED_DEPLOY -s $SPLIT_DEPLOY_DELAY -c $CLONE_NEW_OOM -d $DELETE_PREV_OOM -w $APPLY_WORKAROUNDS -r $REMOVE_OOM_AT_END"
76   echo "provide onap-parameters.yaml(amsterdam) or dev0.yaml+dev1.yaml (master) and aai-cloud-region-put.json"
77   echo "provide a dev0.yaml and dev1.yaml override (0=platform, 1=rest of pods) - copy from https://git.onap.org/oom/tree/kubernetes/onap/resources/environments/dev.yaml"
78
79   if [[ "$BRANCH" == "beijing" ]]; then
80     echo "beijing install deployment no longer supported for a full install because of the configmap 1g limit  - use casablanca+ for helm deploy"
81     exit 1
82   fi
83
84   # fix virtual memory for onap-log:elasticsearch under Rancher 1.6.11 - OOM-431
85   sudo sysctl -w vm.max_map_count=262144
86   if [[ "$DELETE_PREV_OOM" != false ]]; then
87     echo "remove currently deployed pods"
88     sudo helm list
89     # master/beijing only - not amsterdam
90     if [ "$BRANCH" == "amsterdam" ]; then
91       oom/kubernetes/oneclick/deleteAll.bash -n $ENVIRON
92     else
93       echo "kubectl delete namespace $ENVIRON"
94       # workaround for secondary orchestration in dcae
95       kubectl delete namespace $ENVIRON
96       echo "sleep for 4 min to allow the delete to finish pod terminations before trying a helm delete"
97       sleep 240
98       sudo helm delete --purge $ENVIRON
99     fi
100
101     # verify
102     DELETED=$(kubectl get pods --namespace $ENVIRON | grep -E '0/|1/2|1/3|2/3' | wc -l)
103     echo "showing $DELETED undeleted pods"
104     kubectl get pods --namespace $ENVIRON | grep -E '0/|1/2|1/3|2/3'
105     echo "verify deletion is finished."
106
107     # this block: for very infrequent rogue pods that are out-of-band of kubernetes - they dont delete without a force delete
108     # max number of cycles exits to --force block next
109     local MAX_DELETION_WAIT_PERIODS_BEFORE_RUNNING_FORCE=40 # 10 min
110     while [  $(kubectl get pods --namespace $ENVIRON  | grep -E '0/|1/2|1/3|2/3' | wc -l) -gt 0 ]; do
111       sleep 15
112       echo "waiting for deletions to complete, iterations left: $MAX_DELETION_WAIT_PERIODS_BEFORE_RUNNING_FORCE"
113       # addressing rare occurrence on Terminating instances requiring scripted --force in next merge for LOG-914
114       MAX_DELETION_WAIT_PERIODS_BEFORE_RUNNING_FORCE=$((MAX_DELETION_WAIT_PERIODS_BEFORE_RUNNING_FORCE - 1))
115       if [ "$MAX_DELETION_WAIT_PERIODS_BEFORE_RUNNING_FORCE" -eq 0 ]; then
116         #https://wiki.onap.org/display/DW/ONAP+Development#ONAPDevelopment-WorkingwithJSONPath
117         #export POD_NAMES=$(kubectl get pods --field-selector=status.phase!=Running --all-namespaces -o jsonpath="{.items[*].metadata.name}")
118         export POD_NAMES=$(kubectl get pods --namespace $ENVIRON -o jsonpath="{.items[*].metadata.name}")
119         echo "--force delete on pods: $POD_NAMES"
120         for pod in $POD_NAMES; do
121           echo "running: kubectl delete pods $pod --grace-period=0 --force -n $ENVIRON"
122           kubectl delete pods $pod --grace-period=0 --force -n $ENVIRON
123         done
124       fi
125     done
126
127     echo "Pod deletions completed - running helm undeploy then kubectl delete pv,pvc,secrets,cluserrolebindings"
128     sudo helm undeploy $ENVIRON --purge   
129     # specific to when there is no helm release
130     kubectl delete pv --all
131     kubectl delete pvc --all
132     kubectl delete secrets --all
133     kubectl delete clusterrolebinding --all
134     # keep jenkins 120 sec timeout happy with echos
135     sleep 30
136     echo "List of ONAP Modules - look for terminating pods - should be none - only the kubernetes system"
137     LIST_ALL=$(kubectl get pods --all-namespaces -o wide )
138     echo "${LIST_ALL}"
139
140     # for use by continuous deployment only
141     echo " deleting /dockerdata-nfs/ all onap-* deployment directories - why: some pod config jobs will not run on a non-empty nfs subdir"
142     sudo chmod -R 777 /dockerdata-nfs/*
143     rm -rf /dockerdata-nfs/*
144   fi
145
146   # for use by continuous deployment only
147   if [[ "$CLONE_NEW_OOM" != false ]]; then
148     rm -rf oom
149     echo "pull new oom"
150     git clone -b $BRANCH http://gerrit.onap.org/r/oom
151   fi
152
153   # https://wiki.onap.org/display/DW/OOM+Helm+%28un%29Deploy+plugins
154   sudo cp -R ~/oom/kubernetes/helm/plugins/ ~/.helm
155
156   if [ "$BRANCH" == "amsterdam" ]; then
157     echo "start config pod"
158     # still need to source docker variables
159     source oom/kubernetes/oneclick/setenv.bash
160     #echo "source setenv override"
161     echo "moving onap-parameters.yaml to oom/kubernetes/config"
162     cp onap-parameters.yaml oom/kubernetes/config
163     cd oom/kubernetes/config
164     ./createConfig.sh -n $ENVIRON
165     cd ../../../
166     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."
167     while [  $(kubectl get pods -n onap -a | grep config | grep 0/1 | grep Completed | wc -l) -eq 0 ]; do
168       sleep 15
169       echo "waiting for config pod to complete"
170     done
171   else
172     echo "using dev0|1.yaml in working dir"
173   fi
174
175   # usually the prepull takes up to 25-300 min - however hourly builds will finish the docker pulls before the config pod is finished
176   if [[ "$DOCKER_PREPULL" != false ]]; then
177     echo "pre pull docker images - 40+ min for 75G - use a proxy"
178     sudo wget https://git.onap.org/logging-analytics/plain/deploy/docker_prepull.sh
179     sudo chmod 777 docker_prepull.sh
180     # run only on slave nodes vis cloudformation or heat template
181     sudo ./docker_prepull.sh -b $BRANCH -s $NEXUS3_AND_PORT -v true
182   fi
183
184   echo "start onap pods"
185   if [ "$BRANCH" == "amsterdam" ]; then
186     cd oom/kubernetes/oneclick
187     ./createAll.bash -n $ENVIRON
188     cd ../../../
189   else
190     cd oom/kubernetes/
191     sudo make clean
192     sudo make all
193     sudo make $ENVIRON
194    
195     local DISABLE_CHARTS_YAML=onap/resources/environments/disable-allcharts.yaml
196     local DEV0_YAML=~/dev0.yaml
197     local DEV1_YAML=~/dev1.yaml
198     #sudo helm install local/onap -n onap --namespace $ENVIRON
199     dt="$(date +"%T")"
200     echo "$dt: starting ONAP install"
201     # run an empty deploy first to get a round a random helm deploy failure on a release upgrade failure (deploy plugin runs as upgrade instead of install)
202     echo "deploying empty onap deployment as base 1 of 3"
203     sudo helm deploy onap local/onap --namespace $ENVIRON -f $DISABLE_CHARTS_YAML --verbose
204     # deploy platform pods first - dev0 and dev1 can be the same is required
205     echo "deploying base onap pods as base 2 of 3 - sleep 30 between"
206     sleep 30
207     
208     if [[ "$FULL_MANAGED_DEPLOY" != true ]]; then
209       echo "deploying onap subset based on dev0.yaml - use -f true option to bring up all of onap in sequence"
210       sudo helm deploy onap local/onap --namespace $ENVIRON -f $DISABLE_CHARTS_YAML -f $DEV0_YAML --verbose
211       echo "sleep ${SPLIT_DEPLOY_DELAY} sec to allow base platform pods to complete - without a grep on 0/1|0/2|0/3 non-Complete jobs"
212       sleep $SPLIT_DEPLOY_DELAY
213       echo "deploying rest of onap pods as base 3 of 3"
214       sudo helm deploy onap local/onap --namespace $ENVIRON -f $DISABLE_CHARTS_YAML -f $DEV1_YAML --verbose  
215     else
216       # for now master and casablanca have the same pod structure
217       if [[ "$BRANCH" == "casablanca" ]] || [[ "$BRANCH" == "3.0.0-ONAP" ]] || [[ "$BRANCH" == "3.0.1-ONAP" ]] || [[ "$BRANCH" == "master" ]]; then 
218         if [[ "$BRANCH" == "master" ]]; then
219           # node DCAEGEN2 must deploy after consul, msb and dmaap but not any later than deploy 5
220           DEPLOY_ORDER_POD_NAME_ARRAY=('consul msb dmaap dcaegen2 aaf robot aai esr multicloud oof so sdc sdnc vid policy portal log vfc uui vnfsdk appc clamp cli pomba vvp contrib sniro-emulator')
221           # don't count completed pods
222           DEPLOY_NUMBER_PODS_DESIRED_ARRAY=(4 5 11 11 13 1 15 2 6 17 10 12 11 2 8 6 3 18 2 5 5 5 1 11 11 3 1)
223           # account for podd that have varying deploy times or replicaset sizes
224           # don't count the 0/1 completed pods - and skip most of the ResultSet instances except 1
225           # dcae boostrap is problematic
226           DEPLOY_NUMBER_PODS_PARTIAL_ARRAY=(2 5 11 9 11 1 11 2 6 16 10 12 11 2 8 6 3 18 2 5 5 5 1 9 11 3 1)
227         else
228           # casablanca branches
229           DEPLOY_ORDER_POD_NAME_ARRAY=('consul msb dmaap dcaegen2 aaf robot aai esr multicloud oof so sdc sdnc vid policy portal log vfc uui vnfsdk appc clamp cli pomba vvp contrib sniro-emulator')
230           # don't count completed pods
231           DEPLOY_NUMBER_PODS_DESIRED_ARRAY=(4 5 11 11 13 1 15 2 6 17 10 12 11 2 8 6 3 18 2 5 5 5 1 11 11 3 1) 
232           # account for podd that have varying deploy times or replicaset sizes
233           # don't count the 0/1 completed pods - and skip most of the ResultSet instances except 1
234           # dcae boostrap is problematic
235           DEPLOY_NUMBER_PODS_PARTIAL_ARRAY=(2 5 11 9 11 1 11 2 6 16 10 12 11 2 8 6 3 18 2 5 5 5 1 9 11 3 1)
236         fi
237         echo "deploying for $BRANCH using profile $DEPLOY_ORDER_POD_NAME_ARRAY"
238       else
239         echo "branch $BRANCH not supported or unknown - check with LOG-326 or LOG-898"
240         exit 1
241       fi
242       
243       echo "deploying full onap system in dependency order - in sequence for staged use of hd/ram/network resources"
244       # http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html
245       # iterate over the multidimensional array and build up a deploy list as we deploy each pod
246       local DEPLOY_INDEX=0
247       local PODS_PARTIAL=0
248       local APPENDABLE_ENABLED_FLAGS=
249       for POD_NAME in $DEPLOY_ORDER_POD_NAME_ARRAY; do
250         PODS_PARTIAL=${DEPLOY_NUMBER_PODS_PARTIAL_ARRAY[$DEPLOY_INDEX]}
251         PODS_DESIRED=${DEPLOY_NUMBER_PODS_DESIRED_ARRAY[$DEPLOY_INDEX]}
252         echo "deploying $DEPLOY_INDEX for $POD_NAME - expecting $PODS_PARTIAL of a possible $PODS_DESIRED"
253         DEPLOY_INDEX=$((DEPLOY_INDEX + 1 ))
254         # append --set pod.enabled=true
255         APPENDABLE_ENABLED_FLAGS+=" --set "
256         APPENDABLE_ENABLED_FLAGS+=$POD_NAME
257         APPENDABLE_ENABLED_FLAGS+=".enabled=true"
258         echo $APPENDABLE_ENABLED_FLAGS
259         sudo helm deploy onap local/onap --namespace $ENVIRON -f $DISABLE_CHARTS_YAML  -f $DEV0_YAML $APPENDABLE_ENABLED_FLAGS --verbose
260         #sleep $SPLIT_DEPLOY_DELAY
261         # using name- as a match will bring in some extra pods like so-so-vfc and sdnc-sdnc-portal
262         # however using name-name will not work as some pods are named msb-kube2msb or oof-cmso not oof-oof
263         # using thenamespace-pod will work like onap-oof - keyed on passed in namespace
264         wait_for_pod $ENVIRON-$POD_NAME $PODS_PARTIAL  
265      done
266     fi
267     cd ../../
268   fi
269
270   dt="$(date +"%T")"
271   echo "$dt: wait for all pods up for 15-80 min"
272   FAILED_PODS_LIMIT=0
273   MAX_WAIT_PERIODS=480 # 120 MIN
274   COUNTER=0
275   PENDING_PODS=0
276   while [  $(kubectl get pods --all-namespaces | grep -E '0/|1/2|1/3|2/3' | wc -l) -gt $FAILED_PODS_LIMIT ]; do
277     PENDING=$(kubectl get pods --all-namespaces | grep -E '0/|1/2|1/3|2/3' | wc -l)
278     PENDING_PODS=$PENDING
279     sleep 15
280     LIST_PENDING=$(kubectl get pods --all-namespaces -o wide | grep -E '0/|1/2|1/2|2/3' )
281     echo "${LIST_PENDING}"
282     echo "${PENDING} pending > ${FAILED_PODS_LIMIT} at the ${COUNTER}th 15 sec interval"
283     echo ""
284     COUNTER=$((COUNTER + 1 ))
285     MAX_WAIT_PERIODS=$((MAX_WAIT_PERIODS - 1))
286     if [ "$MAX_WAIT_PERIODS" -eq 0 ]; then
287       FAILED_PODS_LIMIT=800
288     fi
289   done
290
291   echo "report on non-running containers"
292   PENDING=$(kubectl get pods --all-namespaces | grep -E '0/|1/2|1/3|2/3')
293   PENDING_COUNT=$(kubectl get pods --all-namespaces | grep -E '0/|1/2|1/3|2/3' | wc -l)
294   PENDING_COUNT_AAI=$(kubectl get pods -n $ENVIRON | grep aai- | grep -E '0/|1/2|1/3|2/3' | wc -l)
295   if [ "$PENDING_COUNT_AAI" -gt 0 ]; then
296     echo "down-aai=${PENDING_COUNT_AAI}"
297   fi
298
299   # todo don't stop if aai is down
300   PENDING_COUNT_APPC=$(kubectl get pods -n $ENVIRON | grep appc- | grep -E '0/|1/2|1/3|2/3' | wc -l)
301   if [ "$PENDING_COUNT_APPC" -gt 0 ]; then
302     echo "down-appc=${PENDING_COUNT_APPC}"
303   fi
304   PENDING_COUNT_MR=$(kubectl get pods -n $ENVIRON | grep message-router- | grep -E '0/|1/2|1/3|2/3' | wc -l)
305   if [ "$PENDING_COUNT_MR" -gt 0 ]; then
306     echo "down-mr=${PENDING_COUNT_MR}"
307   fi
308   PENDING_COUNT_SO=$(kubectl get pods -n $ENVIRON | grep so- | grep -E '0/|1/2|1/3|2/3' | wc -l)
309   if [ "$PENDING_COUNT_SO" -gt 0 ]; then
310     echo "down-so=${PENDING_COUNT_SO}"
311   fi
312   PENDING_COUNT_POLICY=$(kubectl get pods -n $ENVIRON | grep policy- | grep -E '0/|1/2|1/3|2/3' | wc -l)
313   if [ "$PENDING_COUNT_POLICY" -gt 0 ]; then
314     echo "down-policy=${PENDING_COUNT_POLICY}"
315   fi
316   PENDING_COUNT_PORTAL=$(kubectl get pods -n $ENVIRON | grep portal- | grep -E '0/|1/2|1/3|2/3' | wc -l)
317   if [ "$PENDING_COUNT_PORTAL" -gt 0 ]; then
318     echo "down-portal=${PENDING_COUNT_PORTAL}"
319   fi
320   PENDING_COUNT_LOG=$(kubectl get pods -n $ENVIRON | grep log- | grep -E '0/|1/2|1/3|2/3' | wc -l)
321   if [ "$PENDING_COUNT_LOG" -gt 0 ]; then
322     echo "down-log=${PENDING_COUNT_LOG}"
323   fi
324   PENDING_COUNT_ROBOT=$(kubectl get pods -n $ENVIRON | grep robot- | grep -E '0/|1/2|1/3|2/3' | wc -l)
325   if [ "$PENDING_COUNT_ROBOT" -gt 0 ]; then
326     echo "down-robot=${PENDING_COUNT_ROBOT}"
327   fi
328   PENDING_COUNT_SDC=$(kubectl get pods -n $ENVIRON | grep sdc- | grep -E '0/|1/2|1/3|2/3' | wc -l)
329   if [ "$PENDING_COUNT_SDC" -gt 0 ]; then
330     echo "down-sdc=${PENDING_COUNT_SDC}"
331   fi
332   PENDING_COUNT_SDNC=$(kubectl get pods -n $ENVIRON | grep sdnc- | grep -E '0/|1/2|1/3|2/3' | wc -l)
333   if [ "$PENDING_COUNT_SDNC" -gt 0 ]; then
334     echo "down-sdnc=${PENDING_COUNT_SDNC}"
335   fi
336   PENDING_COUNT_VID=$(kubectl get pods -n $ENVIRON | grep vid- | grep -E '0/|1/2|1/3|2/3' | wc -l)
337   if [ "$PENDING_COUNT_VID" -gt 0 ]; then
338     echo "down-vid=${PENDING_COUNT_VID}"
339   fi
340
341   PENDING_COUNT_AAF=$(kubectl get pods -n $ENVIRON | grep aaf- | grep -E '0/|1/2|1/3|2/3' | wc -l)
342   if [ "$PENDING_COUNT_AAF" -gt 0 ]; then
343     echo "down-aaf=${PENDING_COUNT_AAF}"
344   fi
345   PENDING_COUNT_CONSUL=$(kubectl get pods -n $ENVIRON | grep consul- | grep -E '0/|1/2|1/3|2/3' | wc -l)
346   if [ "$PENDING_COUNT_CONSUL" -gt 0 ]; then
347     echo "down-consul=${PENDING_COUNT_CONSUL}"
348   fi
349   PENDING_COUNT_MSB=$(kubectl get pods -n $ENVIRON | grep msb- | grep -E '0/|1/2|1/3|2/3' | wc -l)
350   if [ "$PENDING_COUNT_MSB" -gt 0 ]; then
351     echo "down-msb=${PENDING_COUNT_MSB}"
352   fi
353   PENDING_COUNT_DCAE=$(kubectl get pods -n $ENVIRON | grep dcaegen2- | grep -E '0/|1/2|1/3|2/3' | wc -l)
354   if [ "$PENDING_COUNT_DCAE" -gt 0 ]; then
355     echo "down-dcae=${PENDING_COUNT_DCAE}"
356   fi
357   PENDING_COUNT_CLI=$(kubectl get pods -n $ENVIRON | grep cli- | grep -E '0/|1/2|1/3|2/3' | wc -l)
358   if [ "$PENDING_COUNT_CLI" -gt 0 ]; then
359     echo "down-cli=${PENDING_COUNT_CLI}"
360   fi
361   PENDING_COUNT_MULTICLOUD=$(kubectl get pods -n $ENVIRON | grep multicloud- | grep -E '0/|1/2|1/3|2/3' | wc -l)
362   if [ "$PENDING_COUNT_MULTICLOUD" -gt 0 ]; then
363     echo "down-multicloud=${PENDING_COUNT_MULTICLOUD}"
364   fi
365   PENDING_COUNT_CLAMP=$(kubectl get pods -n $ENVIRON | grep clamp- | grep -E '0/|1/2|1/3|2/3' | wc -l)
366   if [ "$PENDING_COUNT_CLAMP" -gt 0 ]; then
367     echo "down-clamp=${PENDING_COUNT_CLAMP}"
368   fi
369   PENDING_COUNT_VNFSDK=$(kubectl get pods -n $ENVIRON | grep vnfsdk- | grep -E '0/|1/2|1/3|2/3' | wc -l)
370   if [ "$PENDING_COUNT_VNFSDK" -gt 0 ]; then
371     echo "down-vnfsdk=${PENDING_COUNT_VNFSDK}"
372   fi
373   PENDING_COUNT_UUI=$(kubectl get pods -n $ENVIRON | grep uui- | grep -E '0/|1/2|1/3|2/3' | wc -l)
374   if [ "$PENDING_COUNT_UUI" -gt 0 ]; then
375     echo "down-uui=${PENDING_COUNT_UUI}"
376   fi
377   PENDING_COUNT_VFC=$(kubectl get pods -n $ENVIRON | grep vfc- | grep -E '0/|1/2|1/3|2/3' | wc -l)
378   if [ "$PENDING_COUNT_VFC" -gt 0 ]; then
379     echo "down-vfc=${PENDING_COUNT_VFC}"
380   fi
381   PENDING_COUNT_KUBE2MSB=$(kubectl get pods -n $ENVIRON | grep kube2msb- | grep -E '0/|1/2|1/3|2/3' | wc -l)
382   if [ "$PENDING_COUNT_KUBE2MSB" -gt 0 ]; then
383     echo "down-kube2msb=${PENDING_COUNT_KUBE2MSB}"
384   fi
385   echo "pending containers=${PENDING_COUNT}"
386   echo "${PENDING}"
387
388   echo "check filebeat 2/2|3/3 count for ELK stack logging consumption"
389   FILEBEAT=$(kubectl get pods --all-namespaces -a | grep -E '2/|3/')
390   echo "${FILEBEAT}"
391   echo "sleep 5 min - to allow rest frameworks to finish"
392   sleep 300
393   echo "List of ONAP Modules"
394   LIST_ALL=$(kubectl get pods --all-namespaces -a -o wide )
395   echo "${LIST_ALL}"
396   echo "run healthcheck 2 times to warm caches and frameworks so rest endpoints report properly - see OOM-447"
397
398   echo "curl with aai cert to cloud-region PUT"
399
400   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
401
402   echo "get the cloud region back"
403   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
404
405   # OOM-484 - robot scripts moved
406   cd oom/kubernetes/robot
407   echo "run healthcheck prep 1"
408   # OOM-722 adds namespace parameter
409   if [ "$BRANCH" == "amsterdam" ]; then
410     ./ete-k8s.sh health > ~/health1.out
411   else
412     ./ete-k8s.sh $ENVIRON health > ~/health1.out
413   fi
414   echo "sleep 5 min"
415   sleep 300
416   echo "run healthcheck prep 2"
417   if [ "$BRANCH" == "amsterdam" ]; then
418     ./ete-k8s.sh health > ~/health2.out
419   else
420     ./ete-k8s.sh $ENVIRON health > ~/health2.out
421   fi
422   echo "run healthcheck for real - wait a further 5 min"
423   sleep 300
424   if [ "$BRANCH" == "amsterdam" ]; then
425     ./ete-k8s.sh health
426   else
427     ./ete-k8s.sh $ENVIRON health
428   fi
429   echo "run partial vFW"
430   echo "report results"
431   cd ../../../
432   
433   echo "$(date)"
434   #set +a
435 }
436
437 BRANCH=
438 ENVIRON=onap
439 FULL_MANAGED_DEPLOY=true
440 APPLY_WORKAROUNDS=true
441 DELETE_PREV_OOM=false
442 REMOVE_OOM_AT_END=false
443 CLONE_NEW_OOM=true
444 SPLIT_DEPLOY_DELAY=600
445 DOCKER_PREPULL=false
446 NEXUS3_AND_PORT=nexus3.onap.org:10001
447
448 while getopts ":u:b:e:p:n:s:f:c:d:w:r" PARAM; do
449   case $PARAM in
450     u)
451       usage
452       exit 1
453       ;;
454     b)
455       BRANCH=${OPTARG}
456       ;;
457     e)
458       ENVIRON=${OPTARG}
459       ;;
460     p)
461       DOCKER_PREPULL=${OPTARG}
462       ;;
463     n)
464       NEXUS3_AND_PORT=${OPTARG}
465       ;;
466     s)
467       SPLIT_DEPLOY_DELAY=${OPTARG}
468       ;;
469     f)
470       FULL_MANAGED_DEPLOY=${OPTARG}
471       ;;
472     c)
473       CLONE_NEW_OOM=${OPTARG}
474       ;;
475     d)
476       DELETE_PREV_OOM=${OPTARG}
477       ;;
478     w)
479       APPLY_WORKAROUNDS=${OPTARG}
480       ;;
481     r)
482       REMOVE_OOM_AT_END=${OPTARG}
483       ;;
484     ?)
485       usage
486       exit
487       ;;
488   esac
489 done
490
491 if [[ -z $BRANCH ]]; then
492   usage
493   exit 1
494 fi
495
496 deploy_onap  $BRANCH $ENVIRON $DOCKER_PREPULL $NEXUS3_AND_PORT $SPLIT_DEPLOY_DELAY $FULL_MANAGED_DEPLOY $CLONE_NEW_OOM $DELETE_PREV_OOM $APPLY_WORKAROUNDS $REMOVE_OOM_AT_END
497
498 printf "**** Done ****\n"