diff options
Diffstat (limited to 'kubernetes/oneclick')
-rwxr-xr-x | kubernetes/oneclick/createAll.bash | 29 | ||||
-rwxr-xr-x | kubernetes/oneclick/deleteAll.bash | 27 |
2 files changed, 34 insertions, 22 deletions
diff --git a/kubernetes/oneclick/createAll.bash b/kubernetes/oneclick/createAll.bash index 5a99b19623..b7d6a64ffb 100755 --- a/kubernetes/oneclick/createAll.bash +++ b/kubernetes/oneclick/createAll.bash @@ -27,19 +27,20 @@ check_return_code(){ } create_service_account() { - cmd=`echo kubectl create clusterrolebinding $1-$2-admin-binding --clusterrole=cluster-admin --serviceaccount=$1-$2:default` +# cmd=`echo kubectl create clusterrolebinding $1-$2-admin-binding --clusterrole=cluster-admin --serviceaccount=$1-$2:default` + cmd=`echo kubectl create clusterrolebinding $1-$2-admin-binding --clusterrole=cluster-admin --serviceaccount=$1:default` eval ${cmd} check_return_code $cmd } create_namespace() { - cmd=`echo kubectl create namespace $1-$2` + cmd=`echo kubectl create namespace $1` eval ${cmd} - check_return_code $cmd } create_registry_key() { - cmd=`echo kubectl --namespace $1-$2 create secret docker-registry $3 --docker-server=$4 --docker-username=$5 --docker-password=$6 --docker-email=$7` +# cmd=`echo kubectl --namespace $1-$2 create secret docker-registry $3 --docker-server=$4 --docker-username=$5 --docker-password=$6 --docker-email=$7` +cmd=`echo kubectl --namespace $1 create secret docker-registry $2 --docker-server=$3 --docker-username=$4 --docker-password=$5 --docker-email=$6` eval ${cmd} check_return_code $cmd } @@ -86,8 +87,8 @@ create_onap_helm() { # assign default auth token if [[ -z $ONAP_DEFAULT_AUTH_TOKEN ]]; then - DEFAULT_SECRET=`kubectl get secrets -n $1-$2 | grep default-token | awk '{ print $1}'` - ONAP_DEFAULT_AUTH_TOKEN=`kubectl get secrets $DEFAULT_SECRET -n $1-$2 -o yaml | grep 'token:' | awk '{ print $2}' | base64 --decode` + DEFAULT_SECRET=`kubectl get secrets -n $1 | grep default-token | awk '{ print $1}'` + ONAP_DEFAULT_AUTH_TOKEN=`kubectl get secrets $DEFAULT_SECRET -n $1 -o yaml | grep 'token:' | awk '{ print $2}' | base64 --decode` fi cmd=`echo helm install $LOCATION/$2/ --name $1-$2 --namespace $1 --set nsPrefix=$1,nodePortPrefix=$3,kubeMasterAuthToken=$ONAP_DEFAULT_AUTH_TOKEN ${HELM_VALUES_ADDITION}` @@ -106,6 +107,8 @@ MAX_INSTANCE=5 DU=$ONAP_DOCKER_USER DP=$ONAP_DOCKER_PASS +SINGLE_COMPONENT=false + while getopts ":n:u:s:i:a:du:dp:l:v:" PARAM; do case $PARAM in u) @@ -125,6 +128,7 @@ while getopts ":n:u:s:i:a:du:dp:l:v:" PARAM; do LOCATION=${OPTARG} ;; a) + SINGLE_COMPONENT=true APP=${OPTARG} if [[ -z $APP ]]; then usage @@ -168,19 +172,22 @@ printf "\n********** Creating instance ${INSTANCE} of ONAP with port range ${sta printf "\n********** Creating ONAP: ${ONAP_APPS[*]}\n" +if [ "$SINGLE_COMPONENT" == "false" ] +then + printf "\nCreating namespace **********\n" + create_namespace $NS + + printf "\nCreating registry secret **********\n" + create_registry_key $NS ${NS}-docker-registry-key $ONAP_DOCKER_REGISTRY $DU $DP $ONAP_DOCKER_MAIL +fi printf "\n\n********** Creating deployments for ${HELM_APPS[*]} ********** \n" for i in ${HELM_APPS[@]}; do - printf "\nCreating namespace **********\n" - create_namespace $NS $i printf "\nCreating service account **********\n" create_service_account $NS $i - printf "\nCreating registry secret **********\n" - create_registry_key $NS $i ${NS}-docker-registry-key $ONAP_DOCKER_REGISTRY $DU $DP $ONAP_DOCKER_MAIL - printf "\nCreating deployments and services **********\n" create_onap_helm $NS $i $start diff --git a/kubernetes/oneclick/deleteAll.bash b/kubernetes/oneclick/deleteAll.bash index 53f1d1a9cb..52748bc933 100755 --- a/kubernetes/oneclick/deleteAll.bash +++ b/kubernetes/oneclick/deleteAll.bash @@ -3,8 +3,7 @@ . $(dirname "$0")/setenv.bash delete_namespace() { - _NS=$1-$2 - kubectl delete namespace $_NS + kubectl delete namespace $1 } delete_service_account() { @@ -25,13 +24,18 @@ wait_terminate() { while true; do declare -i _STATUS=0 for i in ${HELM_APPS[@]}; do - kubectl get namespaces $1-$i > /dev/null 2>&1 - if [ "$?" -eq "0" ]; then + kubectl get pods --namespace $1 | grep -w " $i" > /dev/null 2>&1 + if [ "$?" -ne "0" ]; then _STATUS=1 break fi done - if [ "$_STATUS" -eq "0" ]; then + + if [ "$SINGLE_COMPONENT" == "false" ]; then + kubectl get namespaces $1 > /dev/null 2>&1 + _STATUS=$? + fi + if [ "$_STATUS" -ne "0" ]; then break fi sleep 2 @@ -60,7 +64,7 @@ APP= WAIT_TERMINATE=true SKIP_INTERACTIVE_CONFIRMATION=no KUBECTL_CONTEXT= - +SINGLE_COMPONENT=false while getopts ":c:n:u:s:a:yN" PARAM; do case $PARAM in u) @@ -76,6 +80,7 @@ while getopts ":c:n:u:s:a:yN" PARAM; do usage exit 1 fi + SINGLE_COMPONENT=true ;; N) WAIT_TERMINATE=false @@ -128,15 +133,15 @@ fi printf "\n********** Cleaning up ONAP: ${ONAP_APPS[*]}\n" for i in ${HELM_APPS[@]}; do - delete_app_helm $NS $i - delete_namespace $NS $i delete_service_account $NS $i - done -delete_app_helm $NS "config" -kubectl delete namespace $NS +if [ "$SINGLE_COMPONENT" == "false" ] +then + delete_app_helm $NS "config" + delete_namespace $NS +fi if $WAIT_TERMINATE; then wait_terminate $NS |