blob: bc211eeb47d72587b7cea8ea109dc002ae951800 [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
Mandeep Khindad6ea9872017-06-24 11:49:37 -04005usage() {
6 cat <<EOF
7Usage: $0 [PARAMs]
8-u : Display usage
9-n [NAMESPACE] : Kubernetes namespace (required)
10-s false : Exclude services (default: true)
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
Mandeep Khindad6ea9872017-06-24 11:49:37 -040027create_service() {
Munir Ahmad87b01092017-08-09 14:51:11 -040028 sed -i -- 's/nodePort: [0-9]\{2\}[02468]\{1\}/nodePort: '"$3"'/g' ../$2/all-services.yaml
29 sed -i -- 's/nodePort: [0-9]\{2\}[13579]\{1\}/nodePort: '"$4"'/g' ../$2/all-services.yaml
Mandeep Khindad6ea9872017-06-24 11:49:37 -040030 kubectl --namespace $1-$2 create -f ../$2/all-services.yaml
Munir Ahmad87b01092017-08-09 14:51:11 -040031 mv ../$2/all-services.yaml-- ../$2/all-services.yaml
Mandeep Khindad6ea9872017-06-24 11:49:37 -040032}
33
34#MAINs
35NS=
36INCL_SVC=true
37APP=
Munir Ahmad87b01092017-08-09 14:51:11 -040038INSTANCE=1
39MAX_INSTANCE=5
Borislav Glozman5197e2e2017-07-24 10:45:28 +030040DU=$ONAP_DOCKER_USER
41DP=$ONAP_DOCKER_PASS
Mandeep Khindad6ea9872017-06-24 11:49:37 -040042
Munir Ahmad87b01092017-08-09 14:51:11 -040043while getopts ":n:u:s:i:a:du:dp:" PARAM; do
Mandeep Khindad6ea9872017-06-24 11:49:37 -040044 case $PARAM in
45 u)
46 usage
47 exit 1
48 ;;
49 n)
50 NS=${OPTARG}
51 ;;
52 s)
53 INCL_SVC=${OPTARG}
54 ;;
Munir Ahmad87b01092017-08-09 14:51:11 -040055 i)
56 INSTANCE=${OPTARG}
57 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -040058 a)
59 APP=${OPTARG}
60 if [[ -z $APP ]]; then
61 usage
62 exit 1
63 fi
64 ;;
Borislav Glozman5197e2e2017-07-24 10:45:28 +030065 du)
66 DU=${OPTARG}
67 ;;
68 dp)
69 DP=${OPTARG}
70 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -040071 ?)
72 usage
73 exit
74 ;;
75 esac
76done
77
78if [[ -z $NS ]]; then
79 usage
80 exit 1
81fi
82
83if [[ ! -z "$APP" ]]; then
84 ONAP_APPS=($APP)
Mandeep Khindad6ea9872017-06-24 11:49:37 -040085fi
86
Munir Ahmad87b01092017-08-09 14:51:11 -040087if [[ "$INCL_SVC" == true ]]; then
88
89 if [ "$INSTANCE" -gt "$MAX_INSTANCE" ];then
90 printf "\n********** You choose to create ${INSTANCE}th instance of ONAP \n"
91 printf "\n********** Due to port allocation only ${MAX_INSTANCE} instances of ONAP is allowed per kubernetes deployment\n"
92 exit 1
93 fi
94
95 start=$((300+2*INSTANCE))
96 end=$((start+1))
97 printf "\n********** Creating instance ${INSTANCE} of ONAP with port range ${start}00 and ${end}99\n"
98
99fi
100
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400101printf "\n********** Creating up ONAP: ${ONAP_APPS[*]}\n"
102
103for i in ${ONAP_APPS[@]}; do
104 printf "\nCreating namespaces **********\n"
105 create_namespace $NS $i
106
107 if [[ "$INCL_SVC" == true ]]; then
108 printf "\nCreating services **********\n"
Munir Ahmad87b01092017-08-09 14:51:11 -0400109 create_service $NS $i $start $end
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400110 fi
111
112 printf "\n"
113done
114
115printf "\n\n********** Creating deployments for ${ONAP_APPS[*]} ********** \n"
116for i in ${ONAP_APPS[@]}; do
Borislav Glozman5197e2e2017-07-24 10:45:28 +0300117 create_registry_key $NS $i $ONAP_DOCKER_REGISTRY_KEY $ONAP_DOCKER_REGISTRY $DU $DP $ONAP_DOCKER_MAIL
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400118 /bin/bash $i.sh $NS $i 'create'
119done
120
Munir Ahmad87b01092017-08-09 14:51:11 -0400121printf "\n**** Done ****\n"