af300f25cdb60d7c77b0a7c59de3e18247f5d5f1
[oom.git] / kubernetes / oneclick / createAll.bash
1 #!/bin/bash
2
3 . $(dirname "$0")/setenv.bash
4
5 usage() {
6   cat <<EOF
7 Usage: $0 [PARAMs]
8 -u                  : Display usage
9 -n [NAMESPACE]      : Kubernetes namespace (required)
10 -s false            : Exclude services (default: true)
11 -a [APP]            : Specify a specific ONAP component (default: all)
12                       from the following choices:
13                       sdc, aai ,mso, message-router, robot,
14                       vid, sdnc, portal, policy, appc
15 EOF
16 }
17
18 create_namespace() {
19   kubectl create namespace $1-$2
20 }
21
22 create_registry_key() {
23   kubectl --namespace $1-$2 create secret docker-registry $3 --docker-server=$4 --docker-username=$5 --docker-password=$6 --docker-email=$7
24 }
25
26 create_service() {
27   kubectl --namespace $1-$2 create -f ../$2/all-services.yaml
28 }
29
30 #MAINs
31 NS=
32 INCL_SVC=true
33 APP=
34 DU=$ONAP_DOCKER_USER
35 DP=$ONAP_DOCKER_PASS
36
37 while getopts ":n:u:s:a:du:dp:" PARAM; do
38   case $PARAM in
39     u)
40       usage
41       exit 1
42       ;;
43     n)
44       NS=${OPTARG}
45       ;;
46     s)
47       INCL_SVC=${OPTARG}
48       ;;
49     a)
50       APP=${OPTARG}
51       if [[ -z $APP ]]; then
52         usage
53         exit 1
54       fi
55       ;;
56     du)
57       DU=${OPTARG}
58       ;;
59     dp)
60       DP=${OPTARG}
61       ;;
62     ?)
63       usage
64       exit
65       ;;
66   esac
67 done
68
69 if [[ -z $NS ]]; then
70   usage
71   exit 1
72 fi
73
74 if [[ ! -z "$APP" ]]; then
75   ONAP_APPS=($APP)
76 fi
77
78 printf "\n********** Creating up ONAP: ${ONAP_APPS[*]}\n"
79
80 for i in ${ONAP_APPS[@]}; do
81   printf "\nCreating namespaces **********\n"
82   create_namespace $NS $i
83
84   if [[ "$INCL_SVC" == true ]]; then
85     printf "\nCreating services **********\n"
86     create_service $NS $i
87   fi
88
89   printf "\n"
90 done
91
92 printf "\n\n********** Creating deployments for  ${ONAP_APPS[*]} ********** \n"
93 for i in ${ONAP_APPS[@]}; do
94   create_registry_key $NS $i $ONAP_DOCKER_REGISTRY_KEY $ONAP_DOCKER_REGISTRY $DU $DP $ONAP_DOCKER_MAIL
95   /bin/bash $i.sh $NS $i 'create'
96 done
97
98 printf "**** Done ****"