-
John McCabe authored
This commit reorgs the TestDrive section slightly, explicitly calling out the one-line scripts used to start the FaaS stack locally. Signed-off-by:
John McCabe <john@johnmccabe.net>
John McCabe authoredThis commit reorgs the TestDrive section slightly, explicitly calling out the one-line scripts used to start the FaaS stack locally. Signed-off-by:
John McCabe <john@johnmccabe.net>
README.md 6.54 KiB
Functions as a Service (FaaS)
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 and package in Docker/OCI image format
- Portable - runs on existing hardware or public/private cloud - Kubernetes or Docker Swarm
- CLI available with YAML format for templating and defining functions
- Auto-scales as demand increases
Overview of FaaS
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 the Docker Swarm or Kubernetes 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.
CLI walk-through
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 https://cli.openfaas.com | sudo sh
Install the faas-cli which is also available on brew
Clone the samples and templates from Github: