beili.zhou | ab1c1ab | 2017-12-07 12:05:06 -0500 | [diff] [blame] | 1 | ######################################################################################## |
| 2 | # This script wraps {$OOM}/kubernetes/config/createConfig.sh script # |
| 3 | # and will only terminated when the configuration is Completed or failed # |
| 4 | # # |
| 5 | # To run it, just enter the following command: # |
| 6 | # ./autoCreateConfig.bash <namespace, default is "onap"> # |
| 7 | ######################################################################################## |
| 8 | #!/bin/bash |
| 9 | |
| 10 | |
| 11 | NS=$1 |
| 12 | if [[ -z $NS ]] |
| 13 | then |
| 14 | echo "Namespace is not specified, use onap namespace." |
| 15 | NS="onap" |
| 16 | fi |
| 17 | |
| 18 | echo "Create $NS config under config directory..." |
| 19 | cd ../../config |
| 20 | ./createConfig.sh -n $NS |
| 21 | cd - |
| 22 | |
| 23 | |
| 24 | echo "...done : kubectl get namespace |
| 25 | ----------------------------------------------- |
| 26 | >>>>>>>>>>>>>> k8s namespace" |
| 27 | kubectl get namespace |
| 28 | |
| 29 | |
| 30 | echo " |
| 31 | ----------------------------------------------- |
| 32 | >>>>>>>>>>>>>> helm : helm ls --all" |
| 33 | helm ls --all |
| 34 | |
| 35 | |
| 36 | echo " |
| 37 | ----------------------------------------------- |
| 38 | >>>>>>>>>>>>>> pod : kubectl get pods -n $NS -a" |
| 39 | kubectl get pods -n $NS -a |
| 40 | |
| 41 | |
| 42 | while true |
| 43 | do |
| 44 | echo "wait for $NS config pod reach to Completed STATUS" |
| 45 | sleep 5 |
| 46 | echo "-----------------------------------------------" |
| 47 | kubectl get pods -n $NS -a |
| 48 | |
| 49 | status=`kubectl get pods -n $NS -a |grep config |xargs echo | cut -d' ' -f3` |
| 50 | |
| 51 | if [ "$status" = "Completed" ] |
| 52 | then |
| 53 | echo "$NS config is Completed!!!" |
| 54 | break |
| 55 | fi |
| 56 | |
| 57 | if [ "$status" = "Error" ] |
| 58 | then |
| 59 | echo " |
| 60 | $NS config is failed with Error!!! |
| 61 | Logs are:" |
| 62 | kubectl logs config -n $NS -f |
| 63 | break |
| 64 | fi |
| 65 | done |