blob: e408d674774f4b23557a5f10c33ecb64493e1028 [file] [log] [blame]
Mandeep Khindad6ea9872017-06-24 11:49:37 -04001#!/bin/bash
2
Borislav Glozman5197e2e2017-07-24 10:45:28 +03003. $(dirname "$0")/setenv.bash
4
kerenj74d723a2017-08-22 15:27:04 +00005
Mandeep Khindad6ea9872017-06-24 11:49:37 -04006usage() {
7 cat <<EOF
8Usage: $0 [PARAMs]
9-u : Display usage
10-n [NAMESPACE] : Kubernetes namespace (required)
Munir Ahmad87b01092017-08-09 14:51:11 -040011-i [INSTANCE] : ONAP deployment instance # (default: 1)
Mandeep Khindad6ea9872017-06-24 11:49:37 -040012-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
16EOF
17}
18
19create_namespace() {
20 kubectl create namespace $1-$2
21}
22
Borislav Glozman5197e2e2017-07-24 10:45:28 +030023create_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
kerenj74d723a2017-08-22 15:27:04 +000027create_onap_helm() {
kerenj78eff212017-08-29 09:56:36 +000028 helm install ../$2/ --name $1-$2 --namespace $1 --set nsPrefix=$1 --set nodePortPrefix=$3
Mike Elliottd17accd2017-08-14 16:21:40 -040029}
30
31
Mandeep Khindad6ea9872017-06-24 11:49:37 -040032#MAINs
33NS=
34INCL_SVC=true
35APP=
Munir Ahmad87b01092017-08-09 14:51:11 -040036INSTANCE=1
37MAX_INSTANCE=5
Borislav Glozman5197e2e2017-07-24 10:45:28 +030038DU=$ONAP_DOCKER_USER
39DP=$ONAP_DOCKER_PASS
kerenj78eff212017-08-29 09:56:36 +000040_FILES_PATH=$(echo ../$i/templates)
Mandeep Khindad6ea9872017-06-24 11:49:37 -040041
Munir Ahmad87b01092017-08-09 14:51:11 -040042while getopts ":n:u:s:i:a:du:dp:" PARAM; do
Mandeep Khindad6ea9872017-06-24 11:49:37 -040043 case $PARAM in
44 u)
45 usage
46 exit 1
47 ;;
48 n)
49 NS=${OPTARG}
50 ;;
Munir Ahmad87b01092017-08-09 14:51:11 -040051 i)
52 INSTANCE=${OPTARG}
53 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -040054 a)
55 APP=${OPTARG}
56 if [[ -z $APP ]]; then
57 usage
58 exit 1
59 fi
60 ;;
Borislav Glozman5197e2e2017-07-24 10:45:28 +030061 du)
62 DU=${OPTARG}
63 ;;
64 dp)
65 DP=${OPTARG}
66 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -040067 ?)
68 usage
69 exit
70 ;;
71 esac
72done
73
74if [[ -z $NS ]]; then
75 usage
76 exit 1
77fi
78
79if [[ ! -z "$APP" ]]; then
kerenj80102842017-08-24 13:54:21 +000080 HELM_APPS=($APP)
Mandeep Khindad6ea9872017-06-24 11:49:37 -040081fi
82
Munir Ahmad87b01092017-08-09 14:51:11 -040083
kerenj80102842017-08-24 13:54:21 +000084if [ "$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 Ahmad87b01092017-08-09 14:51:11 -040088fi
89
kerenj80102842017-08-24 13:54:21 +000090start=$((300+2*INSTANCE))
91end=$((start+1))
92
93printf "\n********** Creating instance ${INSTANCE} of ONAP with port range ${start}00 and ${end}99\n"
94
95
Mike Elliottd17accd2017-08-14 16:21:40 -040096printf "\n********** Creating ONAP: ${ONAP_APPS[*]}\n"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040097
Mandeep Khindad6ea9872017-06-24 11:49:37 -040098
kerenj80102842017-08-24 13:54:21 +000099printf "\n\n********** Creating deployments for ${HELM_APPS[*]} ********** \n"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400100
kerenj74d723a2017-08-22 15:27:04 +0000101for i in ${HELM_APPS[@]}; do
102 printf "\nCreating namespace **********\n"
103 create_namespace $NS $i
104
105 printf "\nCreating registry secret **********\n"
Mandeep Khinda0e8f8892017-08-25 03:31:17 +0000106 create_registry_key $NS $i ${NS}-docker-registry-key $ONAP_DOCKER_REGISTRY $DU $DP $ONAP_DOCKER_MAIL
kerenj74d723a2017-08-22 15:27:04 +0000107
108 printf "\nCreating deployments and services **********\n"
kerenj78eff212017-08-29 09:56:36 +0000109 create_onap_helm $NS $i $start
kerenj74d723a2017-08-22 15:27:04 +0000110
111 printf "\n"
112done
113
Munir Ahmad87b01092017-08-09 14:51:11 -0400114printf "\n**** Done ****\n"