mirror of https://github.com/linkerd/linkerd2.git
Update bin/web script to take into account linkerd-viz (#5442)
The `get-pod` and `port-forward` functions continue to assume deployments like grafana still live under the `linkerd` namespace. This expands the definition of those functions to be able to specify the namespace. These changes can be solely tested by running `bin/web dev` (follow the instructions in `BUILD.md` for the preliminaries needed).
This commit is contained in:
parent
206b349933
commit
93ec23d2c7
30
bin/web
30
bin/web
|
@ -17,7 +17,7 @@ USAGE: web <command>
|
|||
* integration (cloud|local) - run the integration tests
|
||||
Note: Sauce Connect tunnel must be open for cloud tests
|
||||
* port-forward - setup a tunnel to a controller component and port
|
||||
Example: port-forward controller 8085
|
||||
Example: port-forward linkerd controller 8085
|
||||
* run - run a local server (sans. reloading)
|
||||
* setup - get the environment setup for development
|
||||
Note: any command line options are passed on to yarn
|
||||
|
@ -27,8 +27,8 @@ USAGE
|
|||
}; function --help { '-h' ;}
|
||||
|
||||
check-for-linkerd() {
|
||||
controller_pod=$(get-pod controller)
|
||||
grafana_pod=$(get-pod grafana)
|
||||
controller_pod=$(get-pod linkerd controller)
|
||||
grafana_pod=$(get-pod linkerd-viz grafana)
|
||||
|
||||
if [[ -z "${controller_pod// }" ]]; then
|
||||
err 'Controller is not running. Have you installed Linkerd?'
|
||||
|
@ -59,25 +59,31 @@ build() {
|
|||
}
|
||||
|
||||
get-pod() {
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "usage: bin/${0##*/} get-pod component-name" >&2
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "usage: bin/${0##*/} get-pod namespace component-name" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kubectl --namespace=linkerd get po \
|
||||
--selector=linkerd.io/control-plane-component="$1" \
|
||||
|
||||
selector="linkerd.io/control-plane-component=$2"
|
||||
if [ "$1" == "linkerd-viz" ]; then
|
||||
selector="component=$2"
|
||||
fi
|
||||
|
||||
kubectl --namespace="$1" get po \
|
||||
--selector="$selector" \
|
||||
--field-selector='status.phase==Running' \
|
||||
-o jsonpath='{.items[*].metadata.name}'
|
||||
}
|
||||
|
||||
port-forward() {
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "usage: bin/${0##*/} port-forward component-name port-number" >&2
|
||||
if [ $# -ne 3 ]; then
|
||||
echo "usage: bin/${0##*/} port-forward namespace component-name port-number" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nc -z localhost "$2" || \
|
||||
kubectl --namespace=linkerd port-forward "$(get-pod "$1")" "$2:$2"
|
||||
kubectl --namespace="$1" port-forward "$(get-pod "$1" "$2")" "$3:$3"
|
||||
}
|
||||
|
||||
run() {
|
||||
|
@ -89,8 +95,8 @@ run() {
|
|||
build
|
||||
|
||||
check-for-linkerd && (
|
||||
port-forward controller 8085 &
|
||||
port-forward grafana 3000 &
|
||||
port-forward linkerd controller 8085 &
|
||||
port-forward linkerd-viz grafana 3000 &
|
||||
)
|
||||
|
||||
cd "$ROOT"/web && \
|
||||
|
|
Loading…
Reference in New Issue