22
33set -euo pipefail
44
5+ # Default values
6+ K8S_NAMESPACE=" default"
7+ HELM_NAME=" ${HELM_INSTALLATION_NAME:- servicex} "
8+ SERVICE_TYPE=" "
9+
10+ # Parse arguments
11+ while [[ $# -gt 0 ]]; do
12+ case $1 in
13+ --namespace)
14+ K8S_NAMESPACE=" $2 "
15+ shift 2
16+ ;;
17+ --helm-name)
18+ HELM_NAME=" $2 "
19+ shift 2
20+ ;;
21+ app|minio|db)
22+ SERVICE_TYPE=" $1 "
23+ shift
24+ ;;
25+ -h|--help)
26+ echo " Usage: $0 [app|minio|db] [OPTIONS]"
27+ echo " "
28+ echo " Services:"
29+ echo " app - Port forward to ServiceX app (8000)"
30+ echo " minio - Port forward to Minio (9000)"
31+ echo " db - Port forward to PostgreSQL (5432)"
32+ echo " "
33+ echo " Options:"
34+ echo " --namespace NAMESPACE Kubernetes namespace (default: default)"
35+ echo " --helm-name NAME Helm installation name (default: servicex)"
36+ echo " -h, --help Show this help message"
37+ exit 0
38+ ;;
39+ * )
40+ echo " Error: Unknown argument '$1 '"
41+ echo " Run '$0 --help' for usage information"
42+ exit 1
43+ ;;
44+ esac
45+ done
46+
47+ # Validate service type is provided
48+ if [ -z " $SERVICE_TYPE " ]; then
49+ echo " Error: Service type is required"
50+ echo " Usage: $0 [app|minio|db] [OPTIONS]"
51+ echo " Run '$0 --help' for more information"
52+ exit 1
53+ fi
54+
555# Service configuration
6- case " ${1 :- } " in
56+ case " $SERVICE_TYPE " in
757 app)
8- SERVICE=" servicex -servicex-app"
58+ SERVICE=" ${HELM_NAME} -servicex-app"
959 PORT=" 8000"
1060 ;;
1161 minio)
12- SERVICE=" servicex -minio"
62+ SERVICE=" ${HELM_NAME} -minio"
1363 PORT=" 9000"
1464 ;;
1565 db)
16- SERVICE=" servicex -postgresql"
66+ SERVICE=" ${HELM_NAME} -postgresql"
1767 PORT=" 5432"
1868 ;;
19- * )
20- echo " Usage: $0 [app|minio|db]"
21- echo " app - Port forward to ServiceX app (8000)"
22- echo " minio - Port forward to Minio (9000)"
23- echo " db - Port forward to PostgreSQL (5432)"
24- exit 1
25- ;;
2669esac
2770
2871# Check if service is available
29- echo " Checking if service $SERVICE is available..."
30- while ! kubectl get service " $SERVICE " --namespace=" ${NAMESPACE :- default} " > /dev/null 2>&1 ; do
72+ echo " Checking if service $SERVICE is available in namespace $K8S_NAMESPACE ..."
73+ while ! kubectl get service " $SERVICE " --namespace=" $K8S_NAMESPACE " > /dev/null 2>&1 ; do
3174 echo " Service not found, waiting..."
3275 sleep 2
3376done
3679echo " Checking if pods are running..."
3780while true ; do
3881 # Try to find running pods by looking for endpoints
39- ENDPOINTS=$( kubectl get endpoints " $SERVICE " --namespace=" ${NAMESPACE :- default} " -o jsonpath=' {.subsets[0].addresses}' 2> /dev/null || echo " " )
82+ ENDPOINTS=$( kubectl get endpoints " $SERVICE " --namespace=" $K8S_NAMESPACE " -o jsonpath=' {.subsets[0].addresses}' 2> /dev/null || echo " " )
4083 if [ -n " $ENDPOINTS " ] && [ " $ENDPOINTS " != " null" ]; then
4184 echo " Service has ready endpoints"
4285 break
@@ -56,4 +99,4 @@ cleanup() {
5699trap cleanup SIGINT SIGTERM
57100
58101# Start port forwarding
59- kubectl port-forward --namespace=" ${NAMESPACE :- default} " " svc/$SERVICE " " ${PORT} :${PORT} "
102+ kubectl port-forward --namespace=" $K8S_NAMESPACE " " svc/$SERVICE " " ${PORT} :${PORT} "
0 commit comments