Refresh README (#104)

* Refresh README
- Remove links out to Tweets / earlier development
- Feature CLI usage on front page
This commit is contained in:
Alex Ellis 2017-07-10 08:51:52 +01:00 committed by GitHub
parent e4efd16086
commit 2188dbb43c

148
README.md
View File

@ -3,24 +3,92 @@
[![Build
Status](https://travis-ci.org/alexellis/faas.svg?branch=master)](https://travis-ci.org/alexellis/faas)
FaaS is a framework for building serverless functions on Docker with first class support for metrics. Any UNIX process can be packaged as a function enabling you to consume a range of web events without repetitive boiler-plate coding.
FaaS is a framework for building serverless functions with Docker which has first class support for metrics. Any process can be packaged as a function enabling you to consume a range of web events without repetitive boiler-plate coding.
**Highlights**
* Ease of use through UI portal and *one-click* install
* Write functions in any language for Linux or Windows
* Portable - runs on your own hardware, or any cloud
* CLI available with YAML format for templating and defining functions
* Write functions in any language for Linux or Windows and package in Docker/OCI image format
* Portable - runs on existing hardware or public/private cloud
* Auto-scales as demand increases
## Concept
* Each container has a watchdog process that hosts a web server allowing a post request to be forwarded to a desired process via STDIN. The response is sent back to the caller via STDOUT.
* The API Gateway provides an external route into your functions and collects metrics in Prometheus. The gateway will scale functions according to demand by managing Docker Swarm replicas as throughput increases. A UI is baked in allowing you to invoke functions in your browser and create new ones as needed.
## Overview of FaaS
![Stack](http://blog.alexellis.io/content/images/2017/04/faas_hi.png)
## Closing Keynote at Dockercon 2017
### Function Watchdog
* You can make any Docker image into a serverless function by adding the *Function Watchdog* (a tiny Golang HTTP server)
* The *Function Watchdog* is the entrypoint allowing HTTP requests to be forwarded to the target process via STDIN. The response is sent back to the caller by writing to STDOUT from your application.
### Gateway
* The API Gateway provides an external route into your functions and collects Cloud Native metrics through Prometheus.
* Your API Gateway will scale functions according to demand by altering the service replica count in Docker's Swarm API.
* A UI is baked in allowing you to invoke functions in your browser and create new ones as needed.
### CLI
Any container or process in a Docker container can be a serverless function in FaaS. Using the FaaS CLI you can deploy your functions or quickly create new functions from templates such as Node.js or Python.
Let's have a quick look at an example function `url_ping` which connects to a remote web server and returns the HTTP code from the response. It's written in Python.
```
import requests
def handle(req):
r = requests.get(req, timeout = 1)
print(req +" => " + str(r.status_code))
```
*handler.py*
```
$ curl -sSL cli.get-faas.com | sudo sh
```
*Install the faas-cli which is also available on `brew`*
Define your functions in YAML - or deploy via the API Gateway's UI.
```
provider:
name: faas
gateway: http://localhost:8080
functions:
url_ping:
lang: python
handler: ./sample/url_ping
image: alexellis2/faas-urlping
```
*Example function YAML file - `urlping.yaml`*
```
$ faas-cli -action build -f ./urlping.yaml
```
*Build a Docker image using the Python handler in `./sample/url_ping`*
```
$ faas-cli -action deploy -f ./urlping.yaml
```
*Deploy the new image to the gateway defined in the YAML file.*
> If your gateway is remote or part of a multi-host Swarm - you can also use the CLI to push your image to a remote registry or the Hub with `faas-cli -action push`
```
$ curl -d "https://cli.get-faas.com" http://localhost:8080/function/url_ping/
https://cli.get-faas.com => 200
```
*Test out the function with the URL https://cli.get-faas.com => 200*
[Sample functions](https://github.com/alexellis/faas/tree/master/sample-functions) are available in the Github repository in a range of programming languages.
## Get started with FaaS
### Closing Keynote at Dockercon 2017
Functions as a Service or FaaS was a winner in the Cool Hacks contest for Dockercon 2017.
@ -32,7 +100,7 @@ If you'd like to find the functions I used in the demos head over to the [faas-d
This is my original blog post on FaaS from Janurary: [Functions as a Service blog post](http://blog.alexellis.io/functions-as-a-service/)
## TestDrive
### TestDrive
A one-line script is provided to help you get started quickly. You can test-drive FaaS with a set of sample functions as defined in the provided [docker-compose.yml](https://github.com/alexellis/faas/blob/master/docker-compose.yml) file.
@ -42,6 +110,7 @@ Use your own laptop or the free community-run Docker playground: play-with-docke
[![Try in PWD](https://cdn.rawgit.com/play-with-docker/stacks/cff22438/assets/images/button.png)](http://play-with-docker.com?stack=https://raw.githubusercontent.com/alexellis/faas/master/docker-compose.yml&stack_name=func)
> This doesn't work since it won't clone the Prometheus and AlertManager config.
-->
### [Begin the TestDrive](https://github.com/alexellis/faas/blob/master/TestDrive.md)
Here is a screenshot of the API gateway portal - designed for ease of use.
@ -50,63 +119,24 @@ Here is a screenshot of the API gateway portal - designed for ease of use.
### Community
Have you written a blog about FaaS? Send a Pull Request to the community page below.
* [Read blogs/articles and find events about FaaS](https://github.com/alexellis/faas/blob/master/community.md)
## Package existing code as functions
* [Package your function](https://github.com/alexellis/faas/blob/master/DEV.md)
* [Experimental CLI for templating/deploying functions](https://github.com/alexellis/faas-cli)
If you'd like to join FaaS community Slack channel to chat with contributors or get some help - then send a Tweet to [@alexellisuk](https://twitter.com/alexellisuk/) or open a Github issue.
## Roadmap and contributing
* [Read the Roadmap](https://github.com/alexellis/faas/blob/master/ROADMAP.md)
FaaS is written in Golang and is MIT licensed - contributions are welcomed whether that means providing feedback, testing existing and new feature or hacking on the source. To get started you can checkout the [roadmap and contribution guide](https://github.com/alexellis/faas/blob/master/ROADMAP.md) or [browse the open issues on Github](https://github.com/alexellis/faas/issues).
### Ongoing development/screenshots:
Highlights:
FaaS is still expanding and growing, check out the developments around:
* New: FaaS CLI and easy install via `curl` and `brew`
* New: Windows function support
* Planned: Kubernetes support
* Planned: Asynchronous FaaS functions via NATS Streaming
* [Auto-scaling through Prometheus alerts](https://twitter.com/alexellisuk/status/825295438412709888)
* [Prometheus alert example](https://twitter.com/alexellisuk/status/823262200236277762)
* [Invoke functions through UI](https://twitter.com/alexellisuk/status/823262200236277762)
* [Create new functions through UI](https://twitter.com/alexellisuk/status/835047437588905984)
* [Various sample functions](https://github.com/alexellis/faas/blob/master/docker-compose.yml)
* [Integration between IFTTT and Slack](https://twitter.com/alexellisuk/status/857300138745876483)
* [Mixed Linux / Windows serverless functions](https://github.com/alexellis/faas/pull/79)
* [ARM / Raspberry Pi support](https://gist.github.com/alexellis/665332cd8bd9657c9649d0cd6c2dc187)
## Minimum requirements:
* Docker 1.13 (to support Docker Stacks)
* At least a single host in Docker Swarm Mode. (run `docker swarm init`)
## Additional content
#### Would you prefer a video overview?
**Dockercon closing keynote - Cool Hacks demos with Alexa/Github - April 19th 2017**
[Watch on YouTube](https://www.youtube.com/watch?v=-h2VTE9WnZs&t=961s&list=PLlIapFDp305AiwA17mUNtgi5-u23eHm5j&index=1)
**FaaS tour of features including an Alexa Skill - April 9th 2017**
[Watch on YouTube](https://www.youtube.com/watch?v=BK076ChLKKE)
**FaaS deep dive - 11th Jan 2017**
See how to deploy FaaS onto play-with-docker.com and Docker Swarm in 1-2 minutes. See the sample functions in action and watch the graphs in Prometheus as we ramp up the amount of requests.
* [Deep Dive into Functions as a Service (FaaS) on Docker](https://www.youtube.com/watch?v=sp1B7l5mEzc)
#### Prometheus metrics are built-in
Prometheus is built into FaaS and the sample stack, so you can check throughput for each function individually with a rate function in the UI at port 9090 on your Swarm manager.
If you are new to Prometheus, you can start learning about metrics and monitoring on my blog:
> [Monitor your applications with Prometheus](http://blog.alexellis.io/prometheus-monitoring/)
![Prometheus UI](https://pbs.twimg.com/media/C7bkiT9X0AASVuu.jpg)
You can also link this to a Grafana dashboard and see auto-scaling live in action:
Example of a Grafana dashboard linked to FaaS showing auto-scaling live in action:
![](https://pbs.twimg.com/media/C9caE6CXUAAX_64.jpg:large)