@@ -8,51 +8,80 @@ HELM_CHART_DIR="./kubernetes/charts/sdp"
88RELEASE_NAME=" SDP"
99BACKEND_PORT=8000
1010FRONTEND_PORT=5173
11+ ADMINER_PORT=8080
1112
1213# Get pod names using go-template
1314echo " 🔍 Getting pod names..."
1415PODS=$( kubectl get pods -o go-template --template ' {{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' )
1516
16- # Identify backend and frontend pods
17+ # Identify backend, frontend, and adminer pods
1718BACKEND_POD=" "
1819FRONTEND_POD=" "
20+ ADMINER_POD=" "
1921
2022for pod in $PODS ; do
2123 if echo " $pod " | grep -q " backend" ; then
2224 BACKEND_POD=" $pod "
2325 elif echo " $pod " | grep -q " frontend" ; then
2426 FRONTEND_POD=" $pod "
27+ elif echo " $pod " | grep -q " adminer" ; then
28+ ADMINER_POD=" $pod "
2529 fi
2630done
2731
32+ # Report found pods
2833if [ -z " $BACKEND_POD " ]; then
29- echo " ❌ Could not find backend pod"
30- exit 1
34+ echo " ⚠️ Could not find backend pod, skipping..."
35+ else
36+ echo " ✅ Backend pod: $BACKEND_POD "
3137fi
3238
3339if [ -z " $FRONTEND_POD " ]; then
34- echo " ❌ Could not find frontend pod"
35- exit 1
40+ echo " ⚠️ Could not find frontend pod, skipping..."
41+ else
42+ echo " ✅ Frontend pod: $FRONTEND_POD "
3643fi
3744
38- echo " ✅ Backend pod: $BACKEND_POD "
39- echo " ✅ Frontend pod: $FRONTEND_POD "
45+ if [ -z " $ADMINER_POD " ]; then
46+ echo " ⚠️ Could not find adminer pod, skipping..."
47+ else
48+ echo " ✅ Adminer pod: $ADMINER_POD "
49+ fi
4050
41- # Start port forwarding
51+ # Start port forwarding for available pods
4252echo " 🔌 Starting port forwarding..."
43- echo " 🌐 Backend API: http://localhost:$BACKEND_PORT "
44- echo " 🖥️ Frontend: http://localhost:$FRONTEND_PORT "
4553
46- kubectl port-forward pod/$BACKEND_POD $BACKEND_PORT :8000 &
47- BACKEND_PID=$!
54+ if [ -n " $BACKEND_POD " ]; then
55+ echo " 🌐 Backend API: http://localhost:$BACKEND_PORT "
56+ kubectl port-forward pod/$BACKEND_POD $BACKEND_PORT :8000 &
57+ BACKEND_PID=$!
58+ else
59+ BACKEND_PID=" "
60+ fi
4861
49- kubectl port-forward pod/$FRONTEND_POD $FRONTEND_PORT :80 &
50- FRONTEND_PID=$!
62+ if [ -n " $FRONTEND_POD " ]; then
63+ echo " 🖥️ Frontend: http://localhost:$FRONTEND_PORT "
64+ kubectl port-forward pod/$FRONTEND_POD $FRONTEND_PORT :80 &
65+ FRONTEND_PID=$!
66+ else
67+ FRONTEND_PID=" "
68+ fi
69+
70+ if [ -n " $ADMINER_POD " ]; then
71+ echo " 🛠️ Adminer: http://localhost:$ADMINER_PORT "
72+ kubectl port-forward pod/$ADMINER_POD $ADMINER_PORT :80 &
73+ ADMINER_PID=$!
74+ else
75+ ADMINER_PID=" "
76+ fi
5177
5278# Cleanup on exit
5379cleanup () {
5480 echo " 🛑 Stopping port forwarding..."
55- kill $BACKEND_PID $FRONTEND_PID 2> /dev/null || true
81+ # Only kill PIDs that exist
82+ [ -n " $BACKEND_PID " ] && kill $BACKEND_PID 2> /dev/null || true
83+ [ -n " $FRONTEND_PID " ] && kill $FRONTEND_PID 2> /dev/null || true
84+ [ -n " $ADMINER_PID " ] && kill $ADMINER_PID 2> /dev/null || true
5685 exit 0
5786}
5887trap cleanup INT
0 commit comments