mirror of https://github.com/linkerd/linkerd2.git
Wire up grafana proxying in web dev environment (#2070)
* Wire up grafana proxying in web dev environment * Update based on review feedback Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
This commit is contained in:
parent
d358605269
commit
996fd2b013
39
bin/web
39
bin/web
|
@ -14,7 +14,8 @@ USAGE: web <command>
|
||||||
* build - build the assets
|
* build - build the assets
|
||||||
* dev - run a dev server (with live reloading). Options:
|
* dev - run a dev server (with live reloading). Options:
|
||||||
-p $DEV_PORT
|
-p $DEV_PORT
|
||||||
* port-forward - forward the controller from a running k8s cluster to localhost
|
* port-forward - setup a tunnel to a controller component and port
|
||||||
|
Example: port-forward controller 8085
|
||||||
* run - run a local server (sans. reloading)
|
* run - run a local server (sans. reloading)
|
||||||
* setup - get the environment setup for development
|
* setup - get the environment setup for development
|
||||||
Note: any command line options are passed on to yarn
|
Note: any command line options are passed on to yarn
|
||||||
|
@ -24,9 +25,15 @@ USAGE
|
||||||
}; function --help { -h ;}
|
}; function --help { -h ;}
|
||||||
|
|
||||||
function check-for-linkerd {
|
function check-for-linkerd {
|
||||||
pod=$(get-pod)
|
controller_pod=$(get-pod controller)
|
||||||
|
grafana_pod=$(get-pod grafana)
|
||||||
|
|
||||||
if [[ -z "${pod// }" ]]; then
|
if [[ -z "${controller_pod// }" ]]; then
|
||||||
|
err "Controller is not running. Have you installed Linkerd?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${grafana_pod// }" ]]; then
|
||||||
err "Controller is not running. Have you installed Linkerd?"
|
err "Controller is not running. Have you installed Linkerd?"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -41,7 +48,10 @@ function dev {
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
check-for-linkerd && (port-forward &)
|
check-for-linkerd && (
|
||||||
|
port-forward controller 8085 &
|
||||||
|
port-forward grafana 3000 &
|
||||||
|
)
|
||||||
|
|
||||||
cd $ROOT/web/app && yarn webpack-dev-server --port $DEV_PORT &
|
cd $ROOT/web/app && yarn webpack-dev-server --port $DEV_PORT &
|
||||||
cd $ROOT/web && \
|
cd $ROOT/web && \
|
||||||
|
@ -54,21 +64,34 @@ function build {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-pod {
|
function get-pod {
|
||||||
|
if [[ "$#" -ne 1 ]]; then
|
||||||
|
echo "usage: bin/web get-pod component-name" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
kubectl --namespace=linkerd get po \
|
kubectl --namespace=linkerd get po \
|
||||||
--selector=linkerd.io/control-plane-component=controller \
|
--selector=linkerd.io/control-plane-component=$1 \
|
||||||
--field-selector='status.phase==Running' \
|
--field-selector='status.phase==Running' \
|
||||||
-o jsonpath='{.items[*].metadata.name}'
|
-o jsonpath='{.items[*].metadata.name}'
|
||||||
}
|
}
|
||||||
|
|
||||||
function port-forward {
|
function port-forward {
|
||||||
nc -z localhost 8085 || \
|
if [[ "$#" -ne 2 ]]; then
|
||||||
kubectl --namespace=linkerd port-forward $(get-pod) 8085:8085
|
echo "usage: bin/web port-forward component-name port-number" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
nc -z localhost "$2" || \
|
||||||
|
kubectl --namespace=linkerd port-forward $(get-pod $1) "$2:$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
function run {
|
function run {
|
||||||
build
|
build
|
||||||
|
|
||||||
check-for-linkerd && (port-forward &)
|
check-for-linkerd && (
|
||||||
|
port-forward controller 8085 &
|
||||||
|
port-forward grafana 3000 &
|
||||||
|
)
|
||||||
|
|
||||||
cd $ROOT/web
|
cd $ROOT/web
|
||||||
../bin/go-run . $*
|
../bin/go-run . $*
|
||||||
|
|
Loading…
Reference in New Issue