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 | |
kerenj | 74d723a | 2017-08-22 15:27:04 +0000 | [diff] [blame] | 5 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 6 | usage() { |
| 7 | cat <<EOF |
| 8 | Usage: $0 [PARAMs] |
| 9 | -u : Display usage |
| 10 | -n [NAMESPACE] : Kubernetes namespace (required) |
Munir Ahmad | 87b0109 | 2017-08-09 14:51:11 -0400 | [diff] [blame] | 11 | -i [INSTANCE] : ONAP deployment instance # (default: 1) |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 12 | -a [APP] : Specify a specific ONAP component (default: all) |
| 13 | from the following choices: |
| 14 | sdc, aai ,mso, message-router, robot, |
| 15 | vid, sdnc, portal, policy, appc |
| 16 | EOF |
| 17 | } |
| 18 | |
| 19 | create_namespace() { |
| 20 | kubectl create namespace $1-$2 |
| 21 | } |
| 22 | |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame] | 23 | create_registry_key() { |
| 24 | kubectl --namespace $1-$2 create secret docker-registry $3 --docker-server=$4 --docker-username=$5 --docker-password=$6 --docker-email=$7 |
| 25 | } |
| 26 | |
kerenj | 74d723a | 2017-08-22 15:27:04 +0000 | [diff] [blame] | 27 | create_onap_helm() { |
kerenj | 78eff21 | 2017-08-29 09:56:36 +0000 | [diff] [blame] | 28 | helm install ../$2/ --name $1-$2 --namespace $1 --set nsPrefix=$1 --set nodePortPrefix=$3 |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 32 | #MAINs |
| 33 | NS= |
| 34 | INCL_SVC=true |
| 35 | APP= |
Munir Ahmad | 87b0109 | 2017-08-09 14:51:11 -0400 | [diff] [blame] | 36 | INSTANCE=1 |
| 37 | MAX_INSTANCE=5 |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame] | 38 | DU=$ONAP_DOCKER_USER |
| 39 | DP=$ONAP_DOCKER_PASS |
kerenj | 78eff21 | 2017-08-29 09:56:36 +0000 | [diff] [blame] | 40 | _FILES_PATH=$(echo ../$i/templates) |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 41 | |
Munir Ahmad | 87b0109 | 2017-08-09 14:51:11 -0400 | [diff] [blame] | 42 | while getopts ":n:u:s:i:a:du:dp:" PARAM; do |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 43 | case $PARAM in |
| 44 | u) |
| 45 | usage |
| 46 | exit 1 |
| 47 | ;; |
| 48 | n) |
| 49 | NS=${OPTARG} |
| 50 | ;; |
Munir Ahmad | 87b0109 | 2017-08-09 14:51:11 -0400 | [diff] [blame] | 51 | i) |
| 52 | INSTANCE=${OPTARG} |
| 53 | ;; |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 54 | a) |
| 55 | APP=${OPTARG} |
| 56 | if [[ -z $APP ]]; then |
| 57 | usage |
| 58 | exit 1 |
| 59 | fi |
| 60 | ;; |
Borislav Glozman | 5197e2e | 2017-07-24 10:45:28 +0300 | [diff] [blame] | 61 | du) |
| 62 | DU=${OPTARG} |
| 63 | ;; |
| 64 | dp) |
| 65 | DP=${OPTARG} |
| 66 | ;; |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 67 | ?) |
| 68 | usage |
| 69 | exit |
| 70 | ;; |
| 71 | esac |
| 72 | done |
| 73 | |
| 74 | if [[ -z $NS ]]; then |
| 75 | usage |
| 76 | exit 1 |
| 77 | fi |
| 78 | |
| 79 | if [[ ! -z "$APP" ]]; then |
kerenj | 8010284 | 2017-08-24 13:54:21 +0000 | [diff] [blame] | 80 | HELM_APPS=($APP) |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 81 | fi |
| 82 | |
Munir Ahmad | 87b0109 | 2017-08-09 14:51:11 -0400 | [diff] [blame] | 83 | |
kerenj | 8010284 | 2017-08-24 13:54:21 +0000 | [diff] [blame] | 84 | if [ "$INSTANCE" -gt "$MAX_INSTANCE" ];then |
| 85 | printf "\n********** You choose to create ${INSTANCE}th instance of ONAP \n" |
| 86 | printf "\n********** Due to port allocation only ${MAX_INSTANCE} instances of ONAP is allowed per kubernetes deployment\n" |
| 87 | exit 1 |
Munir Ahmad | 87b0109 | 2017-08-09 14:51:11 -0400 | [diff] [blame] | 88 | fi |
| 89 | |
kerenj | 8010284 | 2017-08-24 13:54:21 +0000 | [diff] [blame] | 90 | start=$((300+2*INSTANCE)) |
| 91 | end=$((start+1)) |
| 92 | |
| 93 | printf "\n********** Creating instance ${INSTANCE} of ONAP with port range ${start}00 and ${end}99\n" |
| 94 | |
| 95 | |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 96 | printf "\n********** Creating ONAP: ${ONAP_APPS[*]}\n" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 97 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 98 | |
kerenj | 8010284 | 2017-08-24 13:54:21 +0000 | [diff] [blame] | 99 | printf "\n\n********** Creating deployments for ${HELM_APPS[*]} ********** \n" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 100 | |
kerenj | 74d723a | 2017-08-22 15:27:04 +0000 | [diff] [blame] | 101 | for i in ${HELM_APPS[@]}; do |
| 102 | printf "\nCreating namespace **********\n" |
| 103 | create_namespace $NS $i |
| 104 | |
| 105 | printf "\nCreating registry secret **********\n" |
Mandeep Khinda | 0e8f889 | 2017-08-25 03:31:17 +0000 | [diff] [blame] | 106 | create_registry_key $NS $i ${NS}-docker-registry-key $ONAP_DOCKER_REGISTRY $DU $DP $ONAP_DOCKER_MAIL |
kerenj | 74d723a | 2017-08-22 15:27:04 +0000 | [diff] [blame] | 107 | |
| 108 | printf "\nCreating deployments and services **********\n" |
kerenj | 78eff21 | 2017-08-29 09:56:36 +0000 | [diff] [blame] | 109 | create_onap_helm $NS $i $start |
kerenj | 74d723a | 2017-08-22 15:27:04 +0000 | [diff] [blame] | 110 | |
| 111 | printf "\n" |
| 112 | done |
| 113 | |
Munir Ahmad | 87b0109 | 2017-08-09 14:51:11 -0400 | [diff] [blame] | 114 | printf "\n**** Done ****\n" |