X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=kubernetes%2Fhelm%2Fplugins%2Fdeploy%2Fdeploy.sh;h=f32281da081544d12006c73c7ad1f902b260e208;hb=412448cb66782befbca7ec3ee22346fe7557aa3d;hp=536be7b4a9b124d01d51e35758beb37f379563a4;hpb=0b7eb9ac71bf40746566b0dd48ddfca56b3dc2aa;p=oom.git diff --git a/kubernetes/helm/plugins/deploy/deploy.sh b/kubernetes/helm/plugins/deploy/deploy.sh index 536be7b4a9..f32281da08 100755 --- a/kubernetes/helm/plugins/deploy/deploy.sh +++ b/kubernetes/helm/plugins/deploy/deploy.sh @@ -22,13 +22,13 @@ You can specify the '--values'/'-f' flag multiple times. The priority will be gi last (right-most) file specified. For example, if both myvalues.yaml and override.yaml contained a key called 'Test', the value set in override.yaml would take precedence: - $ helm deploy demo ./onap --namespace onap -f openstack.yaml -f overrides.yaml + $ helm deploy demo ./onap --namespace onap -f openstack.yaml -f overrides.yaml You can specify the '--set' flag multiple times. The priority will be given to the last (right-most) set specified. For example, if both 'bar' and 'newbar' values are set for a key called 'foo', the 'newbar' value would take precedence: - $ helm deploy demo local/onap --namespace onap -f overrides.yaml --set log.enabled=false --set vid.enabled=false + $ helm deploy demo local/onap --namespace onap -f overrides.yaml --set log.enabled=false --set vid.enabled=false Usage: helm deploy [RELEASE] [CHART] [flags] @@ -87,11 +87,25 @@ resolve_deploy_flags() { echo "$DEPLOY_FLAGS" } + +check_for_dep() { + try=0 + retries=30 + until (kubectl get deployment -n $RELEASE | grep -P "\b$1\b") &>/dev/null; do + (( ++try > retries )) && exit 1 + echo "$1 not found. Retry $try/$retries" + sleep 5 + done + echo "$1 found. Waiting for pod intialisation" + sleep 15 +} + + deploy() { # validate params if [ -z "$1" ] || [ -z "$2" ]; then usage - exit 0 + exit 1 fi RELEASE=$1 @@ -99,11 +113,8 @@ deploy() { FLAGS=$(echo ${@} | sed 's/^ *[^ ]* *[^ ]* *//') CHART_REPO="$(echo "$CHART_URL" | cut -d'/' -f1)" CHART_NAME="$(echo "$CHART_URL" | cut -d'/' -f2)" - if expr "$HELM_VER" : "v3\..*" ; then - CACHE_DIR=~/.local/share/helm/plugins/deploy/cache - else - CACHE_DIR=~/.helm/plugins/deploy/cache - fi + + CACHE_DIR=~/.local/share/helm/plugins/deploy/cache echo "Use cache dir: $CACHE_DIR" CHART_DIR=$CACHE_DIR/$CHART_NAME CACHE_SUBCHART_DIR=$CHART_DIR-subcharts @@ -123,7 +134,7 @@ deploy() { fi # determine if set-last-applied flag is enabled SET_LAST_APPLIED="false" - if expr"$FLAGS" : ".*--set-last-applied.*" ; then + if expr "$FLAGS" : ".*--set-last-applied.*" ; then FLAGS="$(echo $FLAGS| sed -n 's/--set-last-applied//p')" SET_LAST_APPLIED="true" fi @@ -181,9 +192,11 @@ deploy() { # temp hack - parent chart needs common subchart mv $CACHE_SUBCHART_DIR/common $CHART_DIR/charts/ - # disable dependencies - rm $CHART_DIR/requirements.lock - mv $CHART_DIR/requirements.yaml $CHART_DIR/requirements.deploy + # disable dependencies + rm $CHART_DIR/Chart.lock + sed -n '1,/dependencies:/p;/description:/,$p' $CHART_DIR/Chart.yaml | grep -v dependencies > $CHART_DIR/deploy_Chart.yaml + mv $CHART_DIR/Chart.yaml $CHART_DIR/Chart.deploy + mv $CHART_DIR/deploy_Chart.yaml $CHART_DIR/Chart.yaml # compute overrides for parent and all subcharts COMPUTED_OVERRIDES=$CACHE_DIR/$CHART_NAME/computed-overrides.yaml @@ -220,6 +233,13 @@ deploy() { #“helm ls” is an expensive command in that it can take a long time to execute. #So cache the results to prevent repeated execution. ALL_HELM_RELEASES=$(helm ls -q) + + #Deploy the srtimzi-kafka chart in advance. Dependent charts require the entity-operator + #for management of the strimzi crds + helm upgrade -i "${RELEASE}-strimzi" $CACHE_SUBCHART_DIR/strimzi + echo "waiting for ${RELEASE}-strimzi-entity-operator to be deployed" + check_for_dep ${RELEASE}-strimzi-entity-operator + for subchart in * ; do SUBCHART_OVERRIDES=$CACHE_SUBCHART_DIR/$subchart/subchart-overrides.yaml @@ -242,36 +262,28 @@ deploy() { else echo "release \"${RELEASE}-${subchart}\" deployed" fi - # Add annotation last-applied-configuration if set-last-applied flag is set + # Add annotation last-applied-configuration if set-last-applied flag is set if [ "$SET_LAST_APPLIED" = "true" ]; then helm get manifest "${RELEASE}-${subchart}" \ | kubectl apply set-last-applied --create-annotation -n onap -f - \ - > $LOG_FILE.log 2>&1 + > $LOG_FILE.log 2>&1 fi fi - if [ "$DELAY" = "true" ]; then - echo sleep 3m - sleep 180 - fi + if [ "$DELAY" = "true" ]; then + echo sleep 3m + sleep 180 + fi else array=($(echo "$ALL_HELM_RELEASES" | grep "${RELEASE}-${subchart}")) n=${#array[*]} for i in $(seq $(($n-1)) -1 0); do - if expr "$HELM_VER" : "v3\..*" ; then - helm del "${array[i]}" - else - helm del "${array[i]}" --purge - fi + helm del "${array[i]}" done fi done # report on success/failures of installs/upgrades - if expr "$HELM_VER" : "v3\..*" ; then - helm ls --all-namespaces | grep -i FAILED | grep $RELEASE - else - helm ls | grep FAILED | grep $RELEASE - fi + helm ls --all-namespaces | grep -i FAILED | grep $RELEASE } HELM_VER=$(helm version --template "{{.Version}}") echo $HELM_VER