Skip to content

Commit e7748f1

Browse files
authored
Add helm installation name and k8s namespace to local/port-forward.sh (#1280)
* update port-forward.sh * separate helm installation name from k8s namespace * update Procfile and documentation to support other helm names
1 parent bc2ca48 commit e7748f1

File tree

3 files changed

+62
-18
lines changed

3 files changed

+62
-18
lines changed

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
minikube-mount-app: minikube mount $LOCAL_DIR:/mnt/servicex
22
minikube-mount-topcp: minikube mount $LOCAL_DIR/code_generator_TopCPToolkit:/mnt/topcp
3-
helm-install: sleep 5; cd $CHART_DIR && helm install -f $VALUES_FILE servicex . && tail -f /dev/null
3+
helm-install: sleep 5; cd $CHART_DIR && helm install -f "$VALUES_FILE" "${HELM_INSTALLATION_NAME:-servicex}" . && tail -f /dev/null
44
port-forward-app: sleep 30 && cd $LOCAL_DIR && bash local/port-forward.sh app
55
port-forward-minio: sleep 20 && cd $LOCAL_DIR && bash local/port-forward.sh minio
66
port-forward-db: sleep 20 && cd $LOCAL_DIR && bash local/port-forward.sh db

docs/development/running_locally.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@ To do this, open your `~/.bashrc` and add the three environment variables previo
109109
LOCAL_DIR=/Users/mattshirley/work/ServiceX/
110110
CHART_DIR=$LOCAL_DIR/helm/servicex
111111
VALUES_FILE=local-values.yaml
112+
# HELM_INSTALLATION_NAME=servicex-local # this is optional, will default to servicex
112113

113114
alias servicex-up='cd $CHART_DIR && overmind start'
114-
alias servicex-down='helm delete servicex'
115+
alias servicex-down='helm delete "${HELM_INSTALLATION_NAME:-servicex}"'
115116
alias servicex-start='servicex-up; servicex-down;'
116-
alias servicex-upgrade='cd $CHART_DIR && helm upgrade -f $VALUES_FILE servicex .'
117+
alias servicex-upgrade='cd $CHART_DIR && helm upgrade -f $VALUES_FILE "${HELM_INSTALLATION_NAME:-servicex}" .'
117118
```
118119

119120
After adding the aliases, refresh your `.bashrc` file:

local/port-forward.sh

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,75 @@
22

33
set -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-
;;
2669
esac
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
3376
done
@@ -36,7 +79,7 @@ done
3679
echo "Checking if pods are running..."
3780
while 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() {
5699
trap 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

Comments
 (0)