mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
updates functions -> fnserver (#516)
* updates functions -> fn-server and fnlb -> fn-lb * changed to fnserver and fnlb
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -29,4 +29,4 @@ tmp/
|
|||||||
fnlb/fnlb
|
fnlb/fnlb
|
||||||
/fn
|
/fn
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/fn-server
|
/fnserver
|
||||||
|
|||||||
10
Makefile
10
Makefile
@@ -8,10 +8,10 @@ dep-up:
|
|||||||
glide up -v
|
glide up -v
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build -o functions
|
go build -o fnserver
|
||||||
|
|
||||||
install:
|
install:
|
||||||
go build -o ${GOPATH}/bin/fn-server
|
go build -o ${GOPATH}/bin/fnserver
|
||||||
|
|
||||||
test:
|
test:
|
||||||
./test.sh
|
./test.sh
|
||||||
@@ -29,17 +29,17 @@ test-build-arm:
|
|||||||
GOARCH=arm64 $(MAKE) build
|
GOARCH=arm64 $(MAKE) build
|
||||||
|
|
||||||
run: build
|
run: build
|
||||||
GIN_MODE=debug ./functions
|
GIN_MODE=debug ./fnserver
|
||||||
|
|
||||||
docker-dep:
|
docker-dep:
|
||||||
# todo: need to create a dep tool image for this (or just ditch this)
|
# todo: need to create a dep tool image for this (or just ditch this)
|
||||||
docker run --rm -it -v ${CURDIR}:/go/src/github.com/fnproject/fn -w /go/src/github.com/fnproject/fn treeder/glide install -v
|
docker run --rm -it -v ${CURDIR}:/go/src/github.com/fnproject/fn -w /go/src/github.com/fnproject/fn treeder/glide install -v
|
||||||
|
|
||||||
docker-build:
|
docker-build:
|
||||||
docker build --build-arg HTTPS_PROXY --build-arg HTTP_PROXY -t fnproject/fn-server:latest .
|
docker build --build-arg HTTPS_PROXY --build-arg HTTP_PROXY -t fnproject/fnserver:latest .
|
||||||
|
|
||||||
docker-run: docker-build
|
docker-run: docker-build
|
||||||
docker run --rm --privileged -it -e NO_PROXY -e HTTP_PROXY -e LOG_LEVEL=debug -e "DB_URL=sqlite3:///app/data/fn.db" -v ${CURDIR}/data:/app/data -p 8080:8080 fnproject/functions
|
docker run --rm --privileged -it -e NO_PROXY -e HTTP_PROXY -e LOG_LEVEL=debug -e "DB_URL=sqlite3:///app/data/fn.db" -v ${CURDIR}/data:/app/data -p 8080:8080 fnproject/fnserver
|
||||||
|
|
||||||
docker-test-run-with-sqlite3:
|
docker-test-run-with-sqlite3:
|
||||||
./api_test.sh sqlite3 4
|
./api_test.sh sqlite3 4
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ func traceWrap(c *gin.Context) {
|
|||||||
func setTracer() {
|
func setTracer() {
|
||||||
var (
|
var (
|
||||||
debugMode = false
|
debugMode = false
|
||||||
serviceName = "fn-server"
|
serviceName = "fnserver"
|
||||||
serviceHostPort = "localhost:8080" // meh
|
serviceHostPort = "localhost:8080" // meh
|
||||||
zipkinHTTPEndpoint = viper.GetString(EnvZipkinURL)
|
zipkinHTTPEndpoint = viper.GetString(EnvZipkinURL)
|
||||||
// ex: "http://zipkin:9411/api/v1/spans"
|
// ex: "http://zipkin:9411/api/v1/spans"
|
||||||
|
|||||||
@@ -21,12 +21,11 @@ function quick() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function build () {
|
function build () {
|
||||||
docker run --rm -v ${pwd}:/go/src/github.com/fnproject/functions -w /go/src/github.com/fnproject/functions golang:alpine go build -o functions-alpine
|
docker run --rm -v ${pwd}:/go/src/github.com/fnproject/fn -w /go/src/github.com/fnproject/fn golang:alpine go build -o fn-alpine
|
||||||
docker build -t fnproject/functions:latest .
|
docker build -t fnproject/fnserver:latest .
|
||||||
}
|
|
||||||
|
|
||||||
function run () {
|
function run () {
|
||||||
docker run --rm --name functions -it -v /var/run/docker.sock:/var/run/docker.sock -e LOG_LEVEL=debug -e "DB_URL=sqlite3:///app/data/fn.db" -v $PWD/data:/app/data -p 8080:8080 fnproject/functions
|
docker run --rm --name functions -it -v /var/run/docker.sock:/var/run/docker.sock -e LOG_LEVEL=debug -e "DB_URL=sqlite3:///app/data/fn.db" -v $PWD/data:/app/data -p 8080:8080 fnproject/fnserver
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($cmd)
|
switch ($cmd)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Fn using BoltDB
|
# Fn using SQLite3
|
||||||
|
|
||||||
SQLite3 is the default database, you just need to run the API.
|
SQLite3 is the default database, you just need to run the API.
|
||||||
|
|
||||||
@@ -6,6 +6,6 @@ SQLite3 is the default database, you just need to run the API.
|
|||||||
|
|
||||||
To keep it persistent, add a volume flag to the command:
|
To keep it persistent, add a volume flag to the command:
|
||||||
|
|
||||||
```
|
```sh
|
||||||
docker run --rm -it --privileged -v $PWD/fn.db:/app/fn.db -p 8080:8080 fnproject/functions
|
docker run --rm -it --privileged -v $PWD/fn.db:/app/fn.db -p 8080:8080 fnproject/fnserver
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,34 +1,34 @@
|
|||||||
# Fn using Postgres
|
# Fn using Postgres
|
||||||
|
|
||||||
Let's presuppose you don't have even a postgres DB ready.
|
Let's suppose you don't have even a postgres DB ready.
|
||||||
|
|
||||||
### 1. Let's start a postgres instance:
|
## 1. Let's start a postgres instance
|
||||||
|
|
||||||
```
|
```sh
|
||||||
docker run --name func-postgres \
|
docker run --name func-postgres \
|
||||||
-e POSTGRES_PASSWORD=funcpass -d postgres
|
-e POSTGRES_PASSWORD=funcpass -d postgres
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Now let's create a new database for Functions
|
## 2. Now let's create a new database for Functions
|
||||||
|
|
||||||
Creating database:
|
Creating database:
|
||||||
|
|
||||||
```
|
```sh
|
||||||
docker run -it --rm --link func-postgres:postgres postgres \
|
docker run -it --rm --link func-postgres:postgres postgres \
|
||||||
psql -h postgres -U postgres -c "CREATE DATABASE funcs;"
|
psql -h postgres -U postgres -c "CREATE DATABASE funcs;"
|
||||||
```
|
```
|
||||||
|
|
||||||
Granting access to postgres user
|
Granting access to postgres user
|
||||||
|
|
||||||
```
|
```sh
|
||||||
docker run -it --rm --link func-postgres:postgres postgres \
|
docker run -it --rm --link func-postgres:postgres postgres \
|
||||||
psql -h postgres -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE funcs TO postgres;'
|
psql -h postgres -U postgres -c 'GRANT ALL PRIVILEGES ON DATABASE funcs TO postgres;'
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Now let's start Functions connecting to our new postgres instance
|
## 3. Now let's start Functions connecting to our new postgres instance
|
||||||
|
|
||||||
```
|
```sh
|
||||||
docker run --rm --privileged --link "func-postgres:postgres" \
|
docker run --rm --privileged --link "func-postgres:postgres" \
|
||||||
-e "DB_URL=postgres://postgres:funcpass@postgres/funcs?sslmode=disable" \
|
-e "DB_URL=postgres://postgres:funcpass@postgres/funcs?sslmode=disable" \
|
||||||
-it -p 8080:8080 fnproject/functions
|
-it -p 8080:8080 fnproject/fnserver
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/fnproject/functions/api/server"
|
"github.com/fnproject/fn/api/server"
|
||||||
"github.com/fnproject/functions/api/models"
|
"github.com/fnproject/fn/api/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type myCustomListener struct{}
|
type myCustomListener struct{}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: fn-service
|
- name: fn-service
|
||||||
image: fnproject/functions:latest
|
image: fnproject/fnserver:latest
|
||||||
securityContext:
|
securityContext:
|
||||||
privileged: true
|
privileged: true
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
This will run with docker in docker.
|
This will run with docker in docker.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run --privileged --rm --name fns -it -v $PWD/data:/app/data -p 80:8080 fnproject/functions
|
docker run --privileged --rm --name fns -it -v $PWD/data:/app/data -p 80:8080 fnproject/fnserver
|
||||||
```
|
```
|
||||||
|
|
||||||
See below for starting without docker in docker.
|
See below for starting without docker in docker.
|
||||||
@@ -37,8 +37,7 @@ The default way to run Fn, as it is in the Quickstart guide, is to use docker-in
|
|||||||
a couple reasons why we did it this way:
|
a couple reasons why we did it this way:
|
||||||
|
|
||||||
* It's clean. Once the container exits, there is nothing left behind including all the function images.
|
* It's clean. Once the container exits, there is nothing left behind including all the function images.
|
||||||
* You can set resource restrictions for the entire Fn instance. For instance, you can set `--memory` on
|
* You can set resource restrictions for the entire Fn instance. For instance, you can set `--memory` on the docker run command to set the max memory for the Fn instance AND all of the functions it's running.
|
||||||
the docker run command to set the max memory for the Fn instance AND all of the functions it's running.
|
|
||||||
|
|
||||||
There are some reasons you may not want to use dind, such as using the image cache during testing or you're running
|
There are some reasons you may not want to use dind, such as using the image cache during testing or you're running
|
||||||
[Windows](windows.md).
|
[Windows](windows.md).
|
||||||
@@ -48,7 +47,7 @@ There are some reasons you may not want to use dind, such as using the image cac
|
|||||||
One way is to mount the host Docker. Everything is essentially the same except you add a `-v` flag:
|
One way is to mount the host Docker. Everything is essentially the same except you add a `-v` flag:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run --rm --name functions -it -v /var/run/docker.sock:/var/run/docker.sock -v $PWD/data:/app/data -p 8080:8080 fnproject/functions
|
docker run --rm --name functions -it -v /var/run/docker.sock:/var/run/docker.sock -v $PWD/data:/app/data -p 8080:8080 fnproject/fnserver
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run outside Docker
|
### Run outside Docker
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Windows doesn't support Docker in Docker so you'll change the run command to the following:
|
Windows doesn't support Docker in Docker so you'll change the run command to the following:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run --rm --name functions -it -v /var/run/docker.sock:/var/run/docker.sock -v ${pwd}/data:/app/data -p 8080:8080 fnproject/functions
|
docker run --rm --name functions -it -v /var/run/docker.sock:/var/run/docker.sock -v ${pwd}/data:/app/data -p 8080:8080 fnproject/fnserver
|
||||||
```
|
```
|
||||||
|
|
||||||
Then everything should work as normal.
|
Then everything should work as normal.
|
||||||
|
|||||||
1
fnlb/.gitignore
vendored
1
fnlb/.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
/fnlb
|
/fnlb
|
||||||
/fnlb-alpine
|
/fnlb-alpine
|
||||||
|
/fnlb
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ If running locally with functions servers in docker, running with docker links
|
|||||||
can make things easier (can use local addresses). for example:
|
can make things easier (can use local addresses). for example:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run -d --name fn-8080 --privileged -p 8080:8080 fnproject/functions:latest
|
docker run -d --name fn-8080 --privileged -p 8080:8080 fnproject/fnserver:latest
|
||||||
docker run -d --name fnlb --link fn-8080 -p 8081:8081 fnproject/fnlb:latest --nodes 127.0.0.1:8080
|
docker run -d --name fnlb --link fn-8080 -p 8081:8081 fnproject/fnlb:latest --nodes 127.0.0.1:8080
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ fn routes create primesapp /primes jconning/primes:0.0.1
|
|||||||
```
|
```
|
||||||
STEP 2: Run five Fn nodes locally. Example (runs five nodes in the background using Docker):
|
STEP 2: Run five Fn nodes locally. Example (runs five nodes in the background using Docker):
|
||||||
```
|
```
|
||||||
sudo docker run -d -it --name functions-8082 --privileged -v ${HOME}/data-8082:/app/data -p 8082:8080 -e "DB_URL=postgres://dbUser:dbPassword@dbHost:5432/dbName" fnproject/functions
|
sudo docker run -d -it --name functions-8082 --privileged -v ${HOME}/data-8082:/app/data -p 8082:8080 -e "DB_URL=postgres://dbUser:dbPassword@dbHost:5432/dbName" fnproject/fnserver
|
||||||
sudo docker run -d -it --name functions-8083 --privileged -v ${HOME}/data-8083:/app/data -p 8083:8080 -e "DB_URL=postgres://dbUser:dbPassword@dbHost:5432/dbName" fnproject/functions
|
sudo docker run -d -it --name functions-8083 --privileged -v ${HOME}/data-8083:/app/data -p 8083:8080 -e "DB_URL=postgres://dbUser:dbPassword@dbHost:5432/dbName" fnproject/fnserver
|
||||||
sudo docker run -d -it --name functions-8084 --privileged -v ${HOME}/data-8084:/app/data -p 8084:8080 -e "DB_URL=postgres://dbUser:dbPassword@dbHost:5432/dbName" fnproject/functions
|
sudo docker run -d -it --name functions-8084 --privileged -v ${HOME}/data-8084:/app/data -p 8084:8080 -e "DB_URL=postgres://dbUser:dbPassword@dbHost:5432/dbName" fnproject/fnserver
|
||||||
sudo docker run -d -it --name functions-8085 --privileged -v ${HOME}/data-8085:/app/data -p 8085:8080 -e "DB_URL=postgres://dbUser:dbPassword@dbHost:5432/dbName" fnproject/functions
|
sudo docker run -d -it --name functions-8085 --privileged -v ${HOME}/data-8085:/app/data -p 8085:8080 -e "DB_URL=postgres://dbUser:dbPassword@dbHost:5432/dbName" fnproject/fnserver
|
||||||
sudo docker run -d -it --name functions-8086 --privileged -v ${HOME}/data-8086:/app/data -p 8086:8080 -e "DB_URL=postgres://dbUser:dbPassword@dbHost:5432/dbName" fnproject/functions
|
sudo docker run -d -it --name functions-8086 --privileged -v ${HOME}/data-8086:/app/data -p 8086:8080 -e "DB_URL=postgres://dbUser:dbPassword@dbHost:5432/dbName" fnproject/fnserver
|
||||||
```
|
```
|
||||||
STEP 3: Run fnlb locally. Example (runs fnlb on the default port 8081):
|
STEP 3: Run fnlb locally. Example (runs fnlb on the default port 8081):
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user