-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathport-forward.sh
More file actions
executable file
·72 lines (58 loc) · 1.6 KB
/
port-forward.sh
File metadata and controls
executable file
·72 lines (58 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
current_dir="`pwd`"
services=(
# The internal service requires a `*` (see `main.go` default flags), put it first so it's easy when adding new service
"dgraphql-internal-v2:7001:9000"
# gRPC services
"abicodec-v2:7002:9000"
"blockmeta-v2:7003:9000"
"search-liverouter-v2:7004:9000"
"search-archive-v2-0:7005:9000"
# HTTP proxy services
"fluxdb-server-v2:8080:80"
"nodeos-api-v2:9999"
)
teardown() {
for job in `jobs -p`; do
kill -s TERM $job &> /dev/null || true
done
}
main() {
if [[ $1 == "--help" || $1 == "-h" ]]; then
usage
exit
fi
trap teardown EXIT
pushd "$ROOT" &> /dev/null
if [[ $1 != "" ]]; then
services=$1; shift
fi
for service in "${services[@]}"; do
name=$(printf $service | cut -f1 -d':')
listen_port=$(printf $service | cut -f2 -d':')
to_port=$(printf $service | cut -f3 -d':')
if [[ $to_port == "" ]]; then
to_port=$listen_port
fi
echo "Forwarding svc/$name (listening on $listen_port, forwarding to $to_port)"
kubectl port-forward svc/$name $listen_port:$to_port 1> /dev/null &
done
echo ""
echo "Press Ctrl+C to terminal all port forwarding"
for job in `jobs -p`; do
wait $job || true
done
}
usage() {
echo "usage: port-forward.sh [<services>]"
echo ""
echo "For development purposes, start port-forwarding of all services known"
echo "to the port specified by the service."
echo ""
echo "By default, these services are port forwarded:"
for service in "${services[@]}"; do
echo "- ${service}"
done
}
main $@