mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
* Move out node-pool manager and replace it with RunnerPool extension * adds extension points for runner pools in load-balanced mode * adds error to return values in RunnerPool and Runner interfaces * Implements runner pool contract with context-aware shutdown * fixes issue with range * fixes tests to use runner abstraction * adds empty test file as a workaround for build requiring go source files in top-level package * removes flappy timeout test * update docs to reflect runner pool setup * refactors system tests to use runner abstraction * removes poolmanager * moves runner interfaces from models to api/runnerpool package * Adds a second runner to pool docs example * explicitly check for request spillover to second runner in test * moves runner pool package name for system tests * renames runner pool pointer variable for consistency * pass model json to runner * automatically cast to http.ResponseWriter in load-balanced call case * allow overriding of server RunnerPool via a programmatic ServerOption * fixes return type of ResponseWriter in test * move Placer interface to runnerpool package * moves hash-based placer out of open source project * removes siphash from Gopkg.lock
102 lines
2.6 KiB
Markdown
102 lines
2.6 KiB
Markdown
# Running load-balanced fn against a pool of runners
|
|
|
|
## Motivation
|
|
|
|
You can run a load-balanced setup for fn to route requests to a group of one or more runners.
|
|
|
|
## Starting the components (as regular processes)
|
|
|
|
### API server
|
|
|
|
```bash
|
|
FN_NODE_TYPE=api ./fnserver
|
|
```
|
|
|
|
### Runners
|
|
|
|
```bash
|
|
mkdir /tmp/runnerdata
|
|
# first runner
|
|
FN_NODE_TYPE=pure-runner FN_PORT=8082 FN_GRPC_PORT=9190 ./fnserver
|
|
# on another terminal, start a second runner
|
|
FN_NODE_TYPE=pure-runner FN_PORT=8083 FN_GRPC_PORT=9191 ./fnserver
|
|
```
|
|
|
|
### LB
|
|
|
|
```bash
|
|
mkdir /tmp/lbdata
|
|
FN_NODE_TYPE=lb FN_PORT=8081 FN_RUNNER_API_URL=http://localhost:8080 FN_RUNNER_ADDRESSES=localhost:9190,localhost:9191 FN_LOG_LEVEL=DEBUG ./fnserver
|
|
```
|
|
|
|
## Starting the components (in Docker containers)
|
|
|
|
### Build the images
|
|
|
|
The images don't yet exist in a registry, so they need building first.
|
|
|
|
```bash
|
|
docker build -f images/lb/Dockerfile -t fnproject/lb:latest .
|
|
docker build -f images/api/Dockerfile -t fnproject/api:latest .
|
|
docker build -f images/runner/Dockerfile -t fnproject/runner:latest .
|
|
```
|
|
|
|
### Start the containers
|
|
|
|
This mode assumes that LB is started with a static set of runners in a single global pool. Note that this configuration does not support runner certificates and is that the communication between LB and runners is unencrypted.
|
|
|
|
### API
|
|
|
|
```
|
|
docker run -d \
|
|
--name api \
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
-p 8080:8080 \
|
|
fnproject/api:latest
|
|
```
|
|
|
|
#### First runner
|
|
```bash
|
|
docker run -d \
|
|
--name runner \
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
-p 9190:9190 \
|
|
-e FN_GRPC_PORT=9190 \
|
|
-p 8095:8080 \
|
|
fnproject/runner:latest
|
|
```
|
|
|
|
#### Second runner
|
|
```bash
|
|
docker run -d \
|
|
--name runner-2 \
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
-p 9191:9191 \
|
|
-e FN_GRPC_PORT=9191 \
|
|
-p 8096:8080 \
|
|
fnproject/runner:latest
|
|
```
|
|
|
|
### LB
|
|
|
|
Retrieve the IP addresses for the runners and the API:
|
|
|
|
```bash
|
|
export RUNNER1=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' runner`
|
|
export RUNNER2=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' runner-2`
|
|
export API=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' api`
|
|
|
|
```
|
|
|
|
Pass in the static set of runners to _FN\_RUNNER\_ADDRESSES_:
|
|
|
|
```bash
|
|
docker run -d \
|
|
--name lb \
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
-p 8081:8080 \
|
|
-e FN_RUNNER_API_URL=http://$API:8080 \
|
|
-e FN_RUNNER_ADDRESSES=$RUNNER1:9190,$RUNNER2:9191 \
|
|
fnproject/lb:latest
|
|
```
|