Alex Ellis (VMware) de2c74fcdb Add feature for graceful shutdown of HTTP server
If the watchdog is sent SIGTERM from an external process then it
should stop accepting new connections and attempt to finish the
work in progress. This change makes use of the new ability in Go
1.9 and onwards to cancel a HTTP server gracefully.

The write_timeout duration is used as a grace period to allow all
in-flight requests to complete. The pattern is taken directly from
the offical example in the Golang documentation. [1]

Further tuning and testing may be needed for Windows containers which
have a different set of signals for closing work. This change aims
to cover the majority use-case for Linux containers.

The HTTP health-check is also invalidated by creating an and
expression with the existing lock file.

Tested with Kubernetes by deploying a custom watchdog and the
fprocess of `env`. Log message was observed when scaling down and
connections stopped being accepted on terminating replica.

Also corrects some typos from previous PR.

[1] https://golang.org/pkg/net/http/#Server.Shutdown

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-24 16:38:46 +00:00
2018-02-14 10:26:58 +00:00
2018-01-28 09:41:52 +00:00
2018-03-10 10:32:23 +01:00
2017-04-29 09:51:14 +01:00
2018-03-09 13:51:38 +01:00
2017-12-20 19:18:38 +00:00
2017-10-09 11:42:39 +01:00
2017-04-27 09:12:15 +01:00
2018-01-14 09:24:18 +00:00
2017-10-01 13:37:12 +02:00
2017-04-29 09:54:34 +01:00
2018-03-18 20:42:03 +00:00
2017-03-21 08:39:36 +00:00
2017-04-27 23:21:50 +01:00
2017-09-24 09:49:25 +01:00
2017-11-04 11:38:36 +00:00
2018-03-17 12:29:09 +00:00

OpenFaaS - Serverless Functions Made Simple

Go Report Card Build
Status GoDoc License: MIT OpenFaaS

OpenFaaS Logo

OpenFaaS (Functions as a Service) is a framework for building serverless functions with Docker and Kubernetes 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.

Twitter URL

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 and Docker Swarm native
  • CLI available with YAML format for templating and defining functions
  • Auto-scales as demand increases

New: become an OpenFaaS backer or sponsor

We need your support to keep delivering on Serverless Functions Made Simple so pledge to OpenFaaS and become a backer or a sponsor with a unique set of rewards. Help us hit our goals and get to back a great project at the same time.

View the List of backers and sponsors

Press-kit/media/swag

For stickers, swag, media or press-kit information head over to openfaas/media

Governance

OpenFaaS is an independent project created by Alex Ellis which is now being built and shaped by a growing community of contributors. Project website: openfaas.com.

Overview of OpenFaaS

Serverless Functions Made Simple.

Stack

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.

API Gateway / UI Portal

  • 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.

The API Gateway is a RESTful micro-service and you can view the Swagger docs here.

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 quickly.

Create new functions from templates for Node.js, Python, Go and many more. If you can't find a suitable template you can also use a Dockerfile.

The CLI is effectively a RESTful client for the API Gateway.

When you have OpenFaaS configured you can get started with the CLI here

Function examples

You can generate new functions using the FaaS-CLI and built-in templates or use any binary for Windows or Linux in a Docker container.

  • Python example:
import requests

def handle(req):
    r =  requests.get(req, timeout = 1)
    print(req +" => " + str(r.status_code))

handler.py

  • Node.js example:
"use strict"

module.exports = (callback, context) => {
    callback(null, {"message": "You said: " + context})
}

handler.js

Other Sample functions are available in the Github repository in a range of programming languages.

Documentation

View our guides for documentation, deployment guides and tutorials.

Get started with OpenFaaS

TestDrive

Docker Swarm

The deployment guide for Docker Swarm contains a simple one-line command to get you up and running in around 60 seconds. It also includes a set of sample functions which you can use with the TestDrive instructions below.

Deployment guide for Docker Swarm

Kubernetes

OpenFaaS is Kubernetes-native - you can follow the deployment guide here.

The new login feature breaks the one-click deployment to PWD. Docker Playground

You can quickly start OpenFaaS on Docker Swarm online using the community-run Docker playground: play-with-docker.com (PWD) by clicking the button below:

Try in PWD

Begin the TestDrive

Here is a screenshot of the API gateway portal - designed for ease of use.

Portal

Find out more about OpenFaaS

SkillsMatter video presentation

Great overview of OpenFaaS features, users and roadmap

OpenFaaS presents to CNCF Serverless workgroup

Closing Keynote at Dockercon 2017

Functions as a Service or FaaS was a winner in the Cool Hacks contest for Dockercon 2017.

If you'd like to find the functions I used in the demos head over to the faas-dockercon repository.

Background story

This is my original blog post on FaaS from January: Functions as a Service blog post

Community

Have you written a blog about OpenFaaS? Send a Pull Request to the community page below.

If you'd like to join OpenFaaS community Slack channel to chat with contributors or get some help - then send a Tweet to @alexellisuk or email alex@openfaas.com.

Roadmap and contributing

OpenFaaS 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 read the roadmap and contribution guide or:

Highlights:

  • New: Kubernetes support via FaaS-netes plugin
  • New: FaaS CLI and easy install via curl and brew
  • New: Windows function support
  • New: Asynchronous/long-running OpenFaaS functions via NATS Streaming - Follow this guide

How do I become a contributor?

Anyone is invited to contribute to the project in-line with the contribution guide - you can also read the guide for ideas on how to get involved. We invite new contributors to join our Slack community. We would also ask you to propose any changes or contributions ahead of time, especially when there is no issue or proposal already tracking it.

Other

Example of a Grafana dashboards linked to OpenFaaS showing auto-scaling live in action: here

An alternative community dashboard is available here

Languages
Go 80.7%
HTML 15.7%
JavaScript 1.5%
Dockerfile 1.3%
Makefile 0.8%