Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions quickstart/expose-keptn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,20 @@ do
# echo "retries: $retries / $MAX_RETRIES"
if [ ${http_code} -eq 200 ]; then
echo "Attempting to open Keptn bridge on http://$INGRESS_IP.nip.io:$INGRESS_PORT/bridge"
if ! command -v open &> /dev/null

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OPEN=('xdg-open')
else
OPEN=('open')
Comment thread
TannerGabriel marked this conversation as resolved.
fi

if ! command -v "${OPEN[@]}" &> /dev/null
then
echo "Open command not found. Printing connection details instead"
echo http://$INGRESS_IP.nip.io:$INGRESS_PORT/bridge
break
else
open http://$INGRESS_IP.nip.io:$INGRESS_PORT/bridge
break
"${OPEN[@]}" http://$INGRESS_IP.nip.io:$INGRESS_PORT/bridge
fi
fi
echo "Keptn bridge not yet available, waiting $SLEEP_TIME seconds and then trying again"
Expand Down
126 changes: 66 additions & 60 deletions quickstart/multistage-delivery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,86 +10,86 @@ SLOW_VERSION=v0.1.2
#source <(curl -s https://raw.githubusercontent.com/keptn/keptn/0.8.5/test/utils.sh)

function print_headline() {
HEADLINE=$1

echo ""
echo "---------------------------------------------------------------------"
echo $HEADLINE
echo "---------------------------------------------------------------------"
echo ""
HEADLINE=$1
echo ""
echo "---------------------------------------------------------------------"
echo $HEADLINE
echo "---------------------------------------------------------------------"
echo ""
}

function verify_helm_installation(){
if ! command -v helm &> /dev/null
then
echo "Could not find helm. Please install helm to proceed further."
exit
fi
if ! command -v helm &> /dev/null
then
echo "Could not find helm. Please install helm to proceed further."
exit
fi
}

function print_error() {
echo "::error file=${BASH_SOURCE[1]##*/},line=${BASH_LINENO[0]}::$(timestamp) ${*}"
echo "::error file=${BASH_SOURCE[1]##*/},line=${BASH_LINENO[0]}::$(timestamp) ${*}"
}

function verify_test_step() {
if [[ $1 != '0' ]]; then
print_error "$2"
print_error "Keptn test step failed"
exit 1
fi
if [[ $1 != '0' ]]; then
print_error "$2"
print_error "Keptn test step failed"
exit 1
fi
}

function verify_namespace_exists() {
NAMESPACE=$1;

NAMESPACE_LIST=$(eval "kubectl get namespaces -L istio-injection | grep ${NAMESPACE} | awk '/$NAMESPACE/'" | awk '{print $1}')

if [[ -z "$NAMESPACE_LIST" ]]; then
print_error "Could not find namespace ${NAMESPACE}"
exit 2
else
echo "Found namespace ${NAMESPACE}"
fi
NAMESPACE=$1;
NAMESPACE_LIST=$(eval "kubectl get namespaces -L istio-injection | grep ${NAMESPACE} | awk '/$NAMESPACE/'" | awk '{print $1}')
if [[ -z "$NAMESPACE_LIST" ]]; then
print_error "Could not find namespace ${NAMESPACE}"
exit 2
else
echo "Found namespace ${NAMESPACE}"
fi
}

# wait for a deployment to be up and running
function wait_for_deployment_in_namespace() {
DEPLOYMENT=$1; NAMESPACE=$2;
RETRY=0; RETRY_MAX=10;

while [[ $RETRY -lt $RETRY_MAX ]]; do
DEPLOYMENT_LIST=$(eval "kubectl get deployments -n ${NAMESPACE} | awk '/$DEPLOYMENT /'" | awk '{print $1}') # list of multiple deployments when starting with the same name
if [[ -z "$DEPLOYMENT_LIST" ]]; then
RETRY=$((RETRY+1))
echo "Retry: ${RETRY}/${RETRY_MAX} - Deployment not found - waiting 15s for deployment ${DEPLOYMENT} in namespace ${NAMESPACE}"
sleep 15
else
READY_REPLICAS=$(eval kubectl get deployments "$DEPLOYMENT" -n "$NAMESPACE" -o=jsonpath='{$.status.availableReplicas}')
WANTED_REPLICAS=$(eval kubectl get deployments "$DEPLOYMENT" -n "$NAMESPACE" -o=jsonpath='{$.spec.replicas}')
UNAVAILABLE_REPLICAS=$(eval kubectl get deployments "$DEPLOYMENT" -n "$NAMESPACE" -o=jsonpath='{$.status.unavailableReplicas}')
if [[ "$READY_REPLICAS" = "$WANTED_REPLICAS" && "$UNAVAILABLE_REPLICAS" = "" ]]; then
echo "Found deployment ${DEPLOYMENT} in namespace ${NAMESPACE}: ${DEPLOYMENT_LIST}"
break
else
RETRY=$((RETRY+1))
echo "Retry: ${RETRY}/${RETRY_MAX} - Unsufficient replicas for deployment - waiting 15s for deployment ${DEPLOYMENT} in namespace ${NAMESPACE}"
sleep 15
fi
DEPLOYMENT=$1; NAMESPACE=$2;
RETRY=0; RETRY_MAX=10;

while [[ $RETRY -lt $RETRY_MAX ]]; do
DEPLOYMENT_LIST=$(eval "kubectl get deployments -n ${NAMESPACE} | awk '/$DEPLOYMENT /'" | awk '{print $1}') # list of multiple deployments when starting with the same name
if [[ -z "$DEPLOYMENT_LIST" ]]; then
RETRY=$((RETRY+1))
echo "Retry: ${RETRY}/${RETRY_MAX} - Deployment not found - waiting 15s for deployment ${DEPLOYMENT} in namespace ${NAMESPACE}"
sleep 15
else
READY_REPLICAS=$(eval kubectl get deployments "$DEPLOYMENT" -n "$NAMESPACE" -o=jsonpath='{$.status.availableReplicas}')
WANTED_REPLICAS=$(eval kubectl get deployments "$DEPLOYMENT" -n "$NAMESPACE" -o=jsonpath='{$.spec.replicas}')
UNAVAILABLE_REPLICAS=$(eval kubectl get deployments "$DEPLOYMENT" -n "$NAMESPACE" -o=jsonpath='{$.status.unavailableReplicas}')
if [[ "$READY_REPLICAS" = "$WANTED_REPLICAS" && "$UNAVAILABLE_REPLICAS" = "" ]]; then
echo "Found deployment ${DEPLOYMENT} in namespace ${NAMESPACE}: ${DEPLOYMENT_LIST}"
break
else
RETRY=$((RETRY+1))
echo "Retry: ${RETRY}/${RETRY_MAX} - Unsufficient replicas for deployment - waiting 15s for deployment ${DEPLOYMENT} in namespace ${NAMESPACE}"
sleep 15
fi
fi
done

if [[ $RETRY == "$RETRY_MAX" ]]; then
print_error "Could not find deployment ${DEPLOYMENT} in namespace ${NAMESPACE}"
exit 1
fi
done

if [[ $RETRY == "$RETRY_MAX" ]]; then
print_error "Could not find deployment ${DEPLOYMENT} in namespace ${NAMESPACE}"
exit 1
fi
}


INGRESS_PORT=$1
INGRESS_IP=127.0.0.1

if [ -z "$INGRESS_PORT" ]; then
INGRESS_PORT=8082
INGRESS_PORT=8082
fi


Expand All @@ -108,7 +108,7 @@ verify_test_step $? "keptn create project command failed."

print_headline "Create a Keptn service"
echo "keptn create service $SERVICE --project=${PROJECT} "
keptn create service $SERVICE --project="${PROJECT}"
keptn create service $SERVICE --project="${PROJECT}"

print_headline "Add Helm chart for $SERVICE"
keptn add-resource --project=$PROJECT --service=$SERVICE --all-stages --resource=./demo/helm/helloservice.tgz --resourceUri=helm/helloservice.tgz
Expand Down Expand Up @@ -199,11 +199,17 @@ echo "Attempt to open Keptn Bridge in 5 seconds..."
echo "Demo setup will continue in the background while you can explore the Keptn Bridge..."
sleep 5

if ! command -v open &> /dev/null
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OPEN=('xdg-open')
else
OPEN=('open')
fi

if ! command -v "${OPEN[@]}" &> /dev/null
then
echo http://$INGRESS_IP.nip.io:$INGRESS_PORT/bridge/project/podtatohead/sequence
echo http://$INGRESS_IP.nip.io:$INGRESS_PORT/bridge/project/podtatohead/sequence
else
open http://$INGRESS_IP.nip.io:$INGRESS_PORT/bridge/project/podtatohead/sequence
"${OPEN[@]}" http://$INGRESS_IP.nip.io:$INGRESS_PORT/bridge/project/podtatohead/sequence
fi


Expand Down