blob: 7b8e2f8886c008349a995f840cfee945d79cc47f [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)
tzvika avnie3cbfa32017-09-07 16:42:37 +030011-v [VALUES] : HELM values filepath (usefull when deploying one component at a time)
tzvika avni67a81112017-09-07 19:43:57 +030012-l [LOCATION] : Location of oom project
Munir Ahmad87b01092017-08-09 14:51:11 -040013-i [INSTANCE] : ONAP deployment instance # (default: 1)
Mandeep Khindad6ea9872017-06-24 11:49:37 -040014-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
18EOF
19}
20
21create_namespace() {
22 kubectl create namespace $1-$2
23}
24
Borislav Glozman5197e2e2017-07-24 10:45:28 +030025create_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
kerenj74d723a2017-08-22 15:27:04 +000029create_onap_helm() {
tzvika avnie3cbfa32017-09-07 16:42:37 +030030 HELM_VALUES_ADDITION=""
tzvika avni67a81112017-09-07 19:43:57 +030031 if [[ ! -z $HELM_VALUES_FILEPATH ]]; then
32 HELM_VALUES_ADDITION="--values=$HELM_VALUES_FILEPATH"
tzvika avnie3cbfa32017-09-07 16:42:37 +030033 fi
tzvika avni67a81112017-09-07 19:43:57 +030034 helm install $LOCATION/$2/ --name $1-$2 --namespace $1 --set nsPrefix=$1,nodePortPrefix=$3 ${HELM_VALUES_ADDITION}
Mike Elliottd17accd2017-08-14 16:21:40 -040035}
36
37
Mandeep Khindad6ea9872017-06-24 11:49:37 -040038#MAINs
39NS=
tzvika avni67a81112017-09-07 19:43:57 +030040HELM_VALUES_FILEPATH=""
41LOCATION="../"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040042INCL_SVC=true
43APP=
Munir Ahmad87b01092017-08-09 14:51:11 -040044INSTANCE=1
45MAX_INSTANCE=5
Borislav Glozman5197e2e2017-07-24 10:45:28 +030046DU=$ONAP_DOCKER_USER
47DP=$ONAP_DOCKER_PASS
Mandeep Khindad6ea9872017-06-24 11:49:37 -040048
tzvika avni67a81112017-09-07 19:43:57 +030049while getopts ":n:u:s:i:a:du:dp:l:v:" PARAM; do
Mandeep Khindad6ea9872017-06-24 11:49:37 -040050 case $PARAM in
51 u)
52 usage
53 exit 1
54 ;;
55 n)
56 NS=${OPTARG}
57 ;;
tzvika avnie3cbfa32017-09-07 16:42:37 +030058 v)
59 HELM_VALUES_FILEPATH=${OPTARG}
60 ;;
Munir Ahmad87b01092017-08-09 14:51:11 -040061 i)
62 INSTANCE=${OPTARG}
63 ;;
tzvika avni67a81112017-09-07 19:43:57 +030064 l)
65 LOCATION=${OPTARG}
66 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -040067 a)
68 APP=${OPTARG}
69 if [[ -z $APP ]]; then
70 usage
71 exit 1
72 fi
73 ;;
Borislav Glozman5197e2e2017-07-24 10:45:28 +030074 du)
75 DU=${OPTARG}
76 ;;
77 dp)
78 DP=${OPTARG}
79 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -040080 ?)
81 usage
82 exit
83 ;;
84 esac
85done
86
87if [[ -z $NS ]]; then
88 usage
89 exit 1
90fi
91
92if [[ ! -z "$APP" ]]; then
kerenj80102842017-08-24 13:54:21 +000093 HELM_APPS=($APP)
Mandeep Khindad6ea9872017-06-24 11:49:37 -040094fi
95
Munir Ahmad87b01092017-08-09 14:51:11 -040096
kerenj80102842017-08-24 13:54:21 +000097if [ "$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 Ahmad87b01092017-08-09 14:51:11 -0400101fi
102
kerenj80102842017-08-24 13:54:21 +0000103start=$((300+2*INSTANCE))
104end=$((start+1))
105
106printf "\n********** Creating instance ${INSTANCE} of ONAP with port range ${start}00 and ${end}99\n"
107
108
Mike Elliottd17accd2017-08-14 16:21:40 -0400109printf "\n********** Creating ONAP: ${ONAP_APPS[*]}\n"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400110
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400111
kerenj80102842017-08-24 13:54:21 +0000112printf "\n\n********** Creating deployments for ${HELM_APPS[*]} ********** \n"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400113
kerenj74d723a2017-08-22 15:27:04 +0000114for i in ${HELM_APPS[@]}; do
115 printf "\nCreating namespace **********\n"
tzvika avni67a81112017-09-07 19:43:57 +0300116 create_namespace $NS $i
kerenj74d723a2017-08-22 15:27:04 +0000117
118 printf "\nCreating registry secret **********\n"
Mandeep Khinda0e8f8892017-08-25 03:31:17 +0000119 create_registry_key $NS $i ${NS}-docker-registry-key $ONAP_DOCKER_REGISTRY $DU $DP $ONAP_DOCKER_MAIL
kerenj74d723a2017-08-22 15:27:04 +0000120
121 printf "\nCreating deployments and services **********\n"
tzvika avni67a81112017-09-07 19:43:57 +0300122 create_onap_helm $NS $i $start
kerenj74d723a2017-08-22 15:27:04 +0000123
124 printf "\n"
125done
126
Munir Ahmad87b01092017-08-09 14:51:11 -0400127printf "\n**** Done ****\n"