Skip to content

Commit

Permalink
add grpc endpoints and enable multiple endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
pfandzelter committed Dec 10, 2020
1 parent d992b98 commit b56b352
Show file tree
Hide file tree
Showing 17 changed files with 688 additions and 93 deletions.
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ T. Pfandzelter and D. Bermbach, **tinyFaaS: A Lightweight FaaS Platform for Edge

### BibTeX

```
```bibtex
@inproceedings{pfandzelter_tinyfaas:_2020,
title = {tinyFaaS: A Lightweight FaaS Platform for Edge Environments},
booktitle = {2020 IEEE International Conference on Fog Computing (ICFC)},
author = {Pfandzelter, Tobias and Bermbach, David},
year = {2020},
publisher = {IEEE},
pages = 17--24
title = {tinyFaaS: A Lightweight FaaS Platform for Edge Environments},
booktitle = {2020 IEEE International Conference on Fog Computing (ICFC)},
author = {Pfandzelter, Tobias and Bermbach, David},
year = {2020},
publisher = {IEEE},
pages = 17--24
}
```

Expand All @@ -29,8 +29,10 @@ The code in this repository is licensed under the terms of the [MIT](./LICENSE)

### Ports

* tcp 8080: management system, anyone who can access this can deploy arbitrary docker containers on your host system
* tcp 5683: http server, this is where your functions will be
- tcp 8080: management system, anyone who can access this can deploy arbitrary docker containers on your host system
- udp 5683: coap server, this is where your functions will be if accessed via the coap endpoint
- tcp 80: http server, this is where your functions will be if accessed via the http endpoint
- tcp 8080: grpc server, this is where your functions will be if accessed via the grpc endpoint

## Instructions

Expand All @@ -53,4 +55,4 @@ docker pull node:10-alpine
`cd` to the src directory and run `./scripts/start.sh`, after that a tinyFaaS instance will run on your host.
To shut down tinyFaaS just run `./scripts/cleanup.sh`
To get an overview of deployed functions run `./scripts/list.sh`
To fetch logs run `./scripts/logs.sh`
To fetch logs run `./scripts/logs.sh`
21 changes: 11 additions & 10 deletions src/management-service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
endpoint_container = {}
function_handlers = {}

def create_endpoint(meta_container, port):
def create_endpoint(meta_container, coapPort, httpPort, grpcPort):
client = docker.from_env()
endpoint_image = client.images.build(path='./reverse-proxy/', rm=True)[0]

Expand All @@ -25,7 +25,7 @@ def create_endpoint(meta_container, port):

endpoint_network = client.networks.create('endpoint-net', driver='bridge')

endpoint_container['container'] = client.containers.run(endpoint_image, network=endpoint_network.name, ports={'5683/tcp': port}, detach=True)
endpoint_container['container'] = client.containers.run(endpoint_image, network=endpoint_network.name, ports={'6000/udp': coapPort, '7000/tcp': httpPort, '8000/tcp': grpcPort}, detach=True)
# getting IP address of the handler container by inspecting the network and converting CIDR to IPv4 address notation (very dirtily, removing the last 3 chars -> i.e. '/20', so let's hope we don't have a /8 subnet mask)
endpoint_container['ipaddr'] = docker.APIClient().inspect_network(endpoint_network.id)['Containers'][endpoint_container['container'].id]['IPv4Address'][:-3]

Expand Down Expand Up @@ -184,14 +184,15 @@ async def get(self):
def main(args):

# default coap port is 5683
port = 5683
coapPort = 5683

if len(args) == 3:
try:
port = int(args[2])
except ValueError:
raise ValueError('Could not parse port number:\n' + json.dumps(args) + '\nUsage: management-service.py [tinyfaas-mgmt container name] <endpoint port>')
elif len(args) != 2:
# http port
httpPort = 80

# grpc port
grpcPort = 8000

if len(args) != 2:
raise ValueError('Too many or too little arguments provided:\n' + json.dumps(args) + '\nUsage: management-service.py [tinyfaas-mgmt container name] <endpoint port>')

meta_container = args[1]
Expand All @@ -202,7 +203,7 @@ def main(args):
raise ValueError('Provided container name does not match a running container' + '\nUsage: management-service.py [tinyfaas-mgmt container name] <endpoint port>')

# create endpoint
create_endpoint(meta_container, port)
create_endpoint(meta_container, coapPort, httpPort, grpcPort)

# accept incoming configuration requests and create handlers based on that
app = tornado.web.Application([
Expand Down
6 changes: 4 additions & 2 deletions src/reverse-proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ RUN CGO_ENABLED=0 go install -v ./...
FROM scratch

EXPOSE 80/tcp
EXPOSE 5683/tcp
EXPOSE 6000/udp
EXPOSE 7000/tcp
EXPOSE 8000/tcp

COPY --from=golang /go/bin/app app
COPY --from=golang /go/bin/reverse-proxy app

ENTRYPOINT [ "./app" ]

Loading

0 comments on commit b56b352

Please sign in to comment.