Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame^] | 3 | . $(dirname "$0")/setenv.bash |
| 4 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 5 | usage() { |
| 6 | cat <<EOF |
| 7 | Usage: $0 [PARAMs] |
| 8 | -u : Display usage |
| 9 | -n [NAMESPACE] : Kubernetes namespace (required) |
| 10 | -s false : Exclude services (default: true) |
| 11 | -a [APP] : Specify a specific ONAP component (default: all) |
| 12 | from the following choices: |
| 13 | sdc, aai ,mso, message-router, robot, |
| 14 | vid, sdnc, portal, policy, appc |
| 15 | EOF |
| 16 | } |
| 17 | |
| 18 | create_namespace() { |
| 19 | kubectl create namespace $1-$2 |
| 20 | } |
| 21 | |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame^] | 22 | create_registry_key() { |
| 23 | kubectl --namespace $1-$2 create secret docker-registry $3 --docker-server=$4 --docker-username=$5 --docker-password=$6 --docker-email=$7 |
| 24 | } |
| 25 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 26 | create_service() { |
| 27 | kubectl --namespace $1-$2 create -f ../$2/all-services.yaml |
| 28 | } |
| 29 | |
| 30 | #MAINs |
| 31 | NS= |
| 32 | INCL_SVC=true |
| 33 | APP= |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame^] | 34 | DU=$ONAP_DOCKER_USER |
| 35 | DP=$ONAP_DOCKER_PASS |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 36 | |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame^] | 37 | while getopts ":n:u:s:a:du:dp:" PARAM; do |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 38 | case $PARAM in |
| 39 | u) |
| 40 | usage |
| 41 | exit 1 |
| 42 | ;; |
| 43 | n) |
| 44 | NS=${OPTARG} |
| 45 | ;; |
| 46 | s) |
| 47 | INCL_SVC=${OPTARG} |
| 48 | ;; |
| 49 | a) |
| 50 | APP=${OPTARG} |
| 51 | if [[ -z $APP ]]; then |
| 52 | usage |
| 53 | exit 1 |
| 54 | fi |
| 55 | ;; |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame^] | 56 | du) |
| 57 | DU=${OPTARG} |
| 58 | ;; |
| 59 | dp) |
| 60 | DP=${OPTARG} |
| 61 | ;; |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 62 | ?) |
| 63 | usage |
| 64 | exit |
| 65 | ;; |
| 66 | esac |
| 67 | done |
| 68 | |
| 69 | if [[ -z $NS ]]; then |
| 70 | usage |
| 71 | exit 1 |
| 72 | fi |
| 73 | |
| 74 | if [[ ! -z "$APP" ]]; then |
| 75 | ONAP_APPS=($APP) |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 76 | fi |
| 77 | |
| 78 | printf "\n********** Creating up ONAP: ${ONAP_APPS[*]}\n" |
| 79 | |
| 80 | for i in ${ONAP_APPS[@]}; do |
| 81 | printf "\nCreating namespaces **********\n" |
| 82 | create_namespace $NS $i |
| 83 | |
| 84 | if [[ "$INCL_SVC" == true ]]; then |
| 85 | printf "\nCreating services **********\n" |
| 86 | create_service $NS $i |
| 87 | fi |
| 88 | |
| 89 | printf "\n" |
| 90 | done |
| 91 | |
| 92 | printf "\n\n********** Creating deployments for ${ONAP_APPS[*]} ********** \n" |
| 93 | for i in ${ONAP_APPS[@]}; do |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame^] | 94 | create_registry_key $NS $i $ONAP_DOCKER_REGISTRY_KEY $ONAP_DOCKER_REGISTRY $DU $DP $ONAP_DOCKER_MAIL |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 95 | /bin/bash $i.sh $NS $i 'create' |
| 96 | done |
| 97 | |
| 98 | printf "**** Done ****" |