+ # State of Deployments
+ DEPLOYMENTS_STATE=$(kubectl get deployment -n ${STACK_NAME} --no-headers 2>&1)
+ DEPLOYMENTS_READY=$(echo "${DEPLOYMENTS_STATE}" | awk '$2=="1/1" && $4=="1" {printf ("%20s\t%s\t%s\n", $1, $2, $4)}')
+ DEPLOYMENTS_NOT_READY=$(echo "${DEPLOYMENTS_STATE}" | awk '$2!="1/1" || $4!="1" {printf ("%20s\t%s\t%s\n", $1, $2, $4)}')
+ COUNT_DEPLOYMENTS_READY=$(echo "${DEPLOYMENTS_READY}"| grep -v -e '^$' | wc -l)
+ COUNT_DEPLOYMENTS_NOT_READY=$(echo "${DEPLOYMENTS_NOT_READY}" | grep -v -e '^$' | wc -l)
+
+ # State of Statefulsets
+ STS_STATE=$(kubectl get statefulset -n ${STACK_NAME} --no-headers 2>&1)
+ STS_READY=$(echo "${STS_STATE}" | awk '$2=="1/1" || $2=="2/2" {printf ("%20s\t%s\t%s\n", $1, $2, $4)}')
+ STS_NOT_READY=$(echo "${STS_STATE}" | awk '$2!="1/1" && $2!="2/2" {printf ("%20s\t%s\t%s\n", $1, $2, $4)}')
+ COUNT_STS_READY=$(echo "${STS_READY}" | grep -v -e '^$' | wc -l)
+ COUNT_STS_NOT_READY=$(echo "${STS_NOT_READY}" | grep -v -e '^$' | wc -l)
+
+ # OK sample
+ if [[ $((${COUNT_DEPLOYMENTS_NOT_READY}+${COUNT_STS_NOT_READY})) -eq 0 ]]
+ then
+ ((++oks_in_a_row))
+ failures_in_a_row=0
+ echo -ne ===\> Successful checks: "${oks_in_a_row}"/${oks_threshold}\\r
+ # NOK sample
+ else
+ ((++failures_in_a_row))
+ oks_in_a_row=0
+ echo
+ echo Bootstraping... "${failures_in_a_row}" attempts of ${failures_threshold}
+
+ # Reports failed deployments
+ if [[ "${COUNT_DEPLOYMENTS_NOT_READY}" -ne 0 ]]
+ then
+ echo ${COUNT_DEPLOYMENTS_NOT_READY} of $((${COUNT_DEPLOYMENTS_NOT_READY}+${COUNT_DEPLOYMENTS_READY})) deployments starting:
+ echo "${DEPLOYMENTS_NOT_READY}"
+ echo
+ fi
+
+ # Reports failed statefulsets
+ if [[ "${COUNT_STS_NOT_READY}" -ne 0 ]]
+ then
+ echo ${COUNT_STS_NOT_READY} of $((${COUNT_STS_NOT_READY}+${COUNT_STS_READY})) statefulsets starting:
+ echo "${STS_NOT_READY}"
+ echo
+ fi