diff --git a/scripts/k8s.sh b/scripts/k8s.sh index 8e7f18e..f8e15e8 100755 --- a/scripts/k8s.sh +++ b/scripts/k8s.sh @@ -32,12 +32,24 @@ fi if [ $CMD = "start" ]; then echo "[+] Appliying use-sprkl into your cluster" USE_SPRKL_ROOT_DIR="$(git rev-parse --show-toplevel)" - helm install use-sprkl $USE_SPRKL_ROOT_DIR/helm/use-sprkl - shop_pod_name=$(kubectl get pod -l app/name=shop -o jsonpath="{.items[0].metadata.name}") + helm upgrade --install use-sprkl $USE_SPRKL_ROOT_DIR/helm/use-sprkl + shop_pod_name="" + retries=0 + while true; do + retries=$((retries+1)) + shop_pod_name=$(kubectl get pod -l app/name=shop -o jsonpath="{.items[0].metadata.name}") + if [[ $retries -gt 10 ]]; then + echo "Error: failed to find shop pod name after 10 retries." + exit 1 + fi + if [[ ! -z $shop_pod_name ]]; then + break + fi + done echo " >> Waiting for shop service to be ready" kubectl wait --for=condition=Ready pod/"$shop_pod_name" - echo " >> Open your browser at http://localhost:5000" - kubectl port-forward "$shop_pod_name" 5000:5000 + echo " >> Open your browser at http://localhost" + sudo kubectl port-forward svc/shop 80:5000 elif [ $CMD = "stop" ]; then echo "[+] Removing use-sprkl from your cluster" helm uninstall use-sprkl