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