2 # shellcheck disable=SC2016
3 # shellcheck source=/dev/null
5 NODE_IP=${1:-10.169.36.152}
8 # Execute in a subshell to prevent local variable override during recursion
10 local total_attempts=$1; shift
13 echo -e "\n[wait_for] Waiting for cmd to return success: ${cmdstr}"
14 # shellcheck disable=SC2034
15 for attempt in $(seq "${total_attempts}"); do
16 echo "[wait_for] Attempt ${attempt}/${total_attempts%.*} for: ${cmdstr}"
17 # shellcheck disable=SC2015
18 eval "${cmdstr}" && echo "[wait_for] OK: ${cmdstr}" && return 0 || true
21 echo "[wait_for] ERROR: Failed after max attempts: ${cmdstr}"
26 # Enable default namespace as auto-inject mode
27 # kubectl label namespace default istio-injection=enabled
29 basepath=$(cd "$(dirname "$0")"; pwd)
30 INFO_YAML=${INFO_YAML:-${basepath}/../config}
32 # TODO(alav): Make each step re-entrant
34 # shellcheck source=/dev/null
35 # Waiting for Istio ready
36 wait_for 100 'test $(kubectl get pods -n istio-system | grep -ce "Running") -eq 12'
39 kubectl apply -f $INFO_YAML/bookinfo.yaml
41 # Waiting for sample case ready
42 wait_for 100 'test $(kubectl get pods | grep -ce "Running") -eq 6'
45 kubectl apply -f $INFO_YAML/bookinfo-gateway.yaml
48 INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
49 # SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].nodePort}')
50 export GATEWAY_URL=$NODE_IP:$INGRESS_PORT
53 curl -s http://${GATEWAY_URL}/productpage | grep -o "<title>.*</title>"