Handle an edge case when using bin/web (#1075)

* Handle an edge case when using bin/web

There's a weird error running `bin/web dev` if you don't have conduit installed on a kubernetes cluster. Nothing in the docs mention that you need to work on this.

Output a user friendly error when we can't find a pod and update the docs to remind folks to install conduit first. Fixes #1070

* Wrap text, send to stderr, fail when missing
This commit is contained in:
Thomas Rampelberg 2018-06-06 16:44:28 -07:00 committed by GitHub
parent bd6b5d0944
commit 9889597c29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 32 deletions

View File

@ -251,8 +251,9 @@ bin/web run
The web server will be running on `localhost:8084`.
Note the `web` process depends on a `public-api` server, for which you have
three options:
Note: by default, this requires a `public-api` server and assumes that it is
running in a Kubernetes cluster. If that isn't the case, you have some other
options:
#### 1. Connect to `public-api` locally
@ -270,29 +271,6 @@ docker-compose stop web
bin/web run --api-addr=$DOCKER_IP:8085
```
#### 3. Connect to `public-api` in Kubernetes
If you are running the public API server in Kubernetes, forward `localhost:8085`
to the Conduit controller pod:
```bash
kubectl --namespace=conduit port-forward $(
kubectl --namespace=conduit get po --selector=conduit.io/control-plane-component=controller -o jsonpath='{.items[*].metadata.name}'
) 8085:8085
```
Note: you can also do this via:
```bash
bin/web port-forward
```
Then connect the local web process to the forwarded port:
```bash
bin/web run --api-addr=localhost:8085
```
### Webpack dev server
To develop with a webpack dev server, run:
@ -301,6 +279,8 @@ To develop with a webpack dev server, run:
bin/web dev
```
Note: you'll want to install conduit on a Kubernetes cluster first.
To add a JS dependency:
```bash

23
bin/web
View File

@ -23,6 +23,15 @@ USAGE: web <command>
USAGE
}; function --help { -h ;}
function check-for-conduit {
pod=$(get-pod)
if [[ -z "${pod// }" ]]; then
err "Controller is not running. Have you installed Conduit?"
exit 1
fi
}
function dev {
build
@ -32,7 +41,7 @@ function dev {
esac
done
port-forward &
check-for-conduit && (port-forward &)
cd $ROOT/web/app && yarn webpack-dev-server --port $DEV_PORT &
cd $ROOT/web && \
@ -44,18 +53,22 @@ function build {
yarn webpack
}
function port-forward {
nc -z localhost 8085 || kubectl --namespace=conduit port-forward $(
function get-pod {
kubectl --namespace=conduit get po \
--selector=conduit.io/control-plane-component=controller \
--field-selector='status.phase==Running' \
-o jsonpath='{.items[*].metadata.name}'
) 8085:8085
}
function port-forward {
nc -z localhost 8085 || \
kubectl --namespace=conduit port-forward $(get-pod) 8085:8085
}
function run {
build
port-forward &
check-for-conduit && (port-forward &)
cd $ROOT/web
../bin/go-run . $*