OpenFaaS framework
Serverless functions for Docker & Kubernetes
OPEN-SOURCE SUMMIT - 11TH SEP
@alexellisuk / openfaas.com
What is Serverless?
MicroserviceMicroserviceMicroservice
Monolith
Microservice
Function
Serverless	evolu*on
“Alexa, how’s
the weather?”
{ “intent”:
“FindWeather” }
{ “speech”:
“It’s 70 degrees” }
Lambda
Function
“Alexa, how’s
the weather?”
{ “intent”:
“FindWeather” }
{ “speech”:
“It’s 70 degrees” }
+
#serverless
OpenFaaS
DRIVING FACTORS
PortabilityEase of use
Simplicity
Open
Platform
How did OpenFaaS come about?
STORY SO FAR
• “Lambda but on containers for Alexa”
• Dockercon Cool Hacks - “push Docker beyond what it was designed to do”
• Major changes since Dockercon
• Top trending Open Source project overall
• > 5.4k stars
• Kubernetes & external provider support
• Asynchronous processing via NATS
• CLI & templating
• Regular contributors & Slack Community
OpenFaaS top contributors and influencers
What are serverless use-cases?
ANYTHING
Image/Video
conversion
Machine
Learning
Mobile Back-
ends / IoT
HTTP
services
Chat Bots
Batch Jobs
What is OpenFaaS?
"A SERVERLESS FRAMEWORK BUILT ON CONTAINERS"
• Basic primitive: containers in OCI format
• Container security
• r/o filesystem, privilege drop, content trust
• Manage functions with scheduler/orchestrator
• Rich container eco-system - commercial & community
• Anything can be a function - polyglot
• Leverage existing skills in teams (including Windows)
• Avoid vendor lock-in
• Run anywhere - cloud or on-prem
Payroll S3	Minio
put	bonus.json
Calculate	Gross
get	bonus.json,

employees.json
MyAssistant
Comes in one flavor: Cloud Native
API Gateway Function Watchdog
Prometheus Swarm Kubernetes
HTTP
body
stdinrequest
stdoutresponse
“/usr/bin/node

handler.js”
headers
body
headers
Forked process
Function watchdog
Performance - fork vs After Burn
HELLO-WORLD & APACHE-BENCH
Deployed in 60 seconds
QUICK DEMO
How do I write a function?
WRITE A HANDLER
def handler(req):
r = requests.get(req)
print(r.status_code)
handler.py
requirements.txt
Python
Template
Docker
Image
requests
$ faas-cli new --lang python --name sample
Container Registry
What languages are available?
SHORT ANSWER - ANY
• Use supported templates
• Edit them or bring your own
• Or go “full Docker”
How do I arrange functions?
provider:
name: faas
gateway: http://localhost:31112
shrink-image:
image: functions/resizer:latest
fprocess: "convert - -resize 50% fd:1”
environment:
MAGICK_FONT_PATH: /fonts
url-ping:
lang: python
handler: ./sample/url-ping
image: alexellis/url-ping
$ faas-cli build -f ./sample.yml
$ faas-cli deploy -f ./sample.yml
YAML STACK
$ faas-cli new --name url-ping --lang python
Build, deploy, invoke
the GIF Maker
ffmpeg
gifsicle
FULL DOCKER EXAMPLE
the GIF Maker
FROM alpine:3.6
ADD https://github.com/alexellis/faas/releases/download/0.5.6-alpha/
fwatchdog /usr/bin/
RUN apk --no-cache add ffmpeg gifsicle
WORKDIR /root/
COPY entry.sh .
ENV fprocess=“./entry.sh"
CMD ["fwatchdog"]
DOCKERFILE
Auto-scaling
DEMO
Mirror East	CoastWest	Coast
Kubernetes support
VIA EXTERNAL PROVIDER
kubernetes
• Rich eco-system
• Large user-base with existing on-prem/
hybrid deployments
• Similar primitives to Docker Swarm
Kubernetes support
VIA EXTERNAL PROVIDER
Gateway faas-netes
UI
CLI
Web
Func 1
Func 1
Func 2
faas-hyper
faas-nomad
Synchronous invocation
IN STORE RETURNS
marshal	request
Gateway Func: resizer
HTTP

200
Resize

Image
Asynchronous invocation
RETURN A PRODUCT BY MAIL
NATS Queue
marshal	request
Gateway Queue-worker
dequeue
Func: resizer
HTTP

200
HTTP

200
Resize

Image
Asynchronous concerns
ADDED COMPLEXITY
• Points	of	failure:	
• Func*on	
• Queue-worker	
• Queue	system
• Func*on	response	
• Store	in	S3	or	aDB	
• Poll	for	result	
• Callback	to	URL?
Composable	complexity
Asynchronous invocation
WITH A CALLBACK-URL
Gateway Func: resizer
HTTP

200
http://x.y.z
X-Callback-Url:	
hUp://x.y.z
X-Callback-Url
Resize

Image
Queue etc
openfaas.com
FanClub GetAvatar
hUps://
S3	bucket
Fanclub
HOW IT WORKS
Providers, integrations and users
What’s next for OpenFaaS?
SET REPLICAS = 10,000
• Roadmap - supporting users
• Evaluating - ADP, Huawei, CodeFresh, MadGlory, IRT Saint Exupery
• Community language templates, helm chart
• AfterBurn optimisations
• Guides, manual & tutorials for developer-clouds
• Get SWAG and get involved
• Contributors, sponsorship and finding a home
• Speaking
• Open-Source Summit, L.A. - Sept
• JeffConf, Milan - Sept
• Dockercon EU, Copenhagen - October - discount code “CaptainAlex”
@alexellisuk
https://www.openfaas.com
Bonus material
FUNCTIONS / DEMOS
• Dockercon closing keynote (video)
Derek
• https://github.com/alexellis/derek
Twitter + Elastic search / Youtube Downloader
• https://github.com/alexellis/journey-expert
Other functions
• https://github.com/alexellis/faas-contributor-stamp
• https://github.com/alexellis/faas-office-sample
• https://github.com/alexellis/faas-img2ansi
Bonus material
WINDOWS DEMO
Bonus material
WINDOWS DEMO
+
External providers
Gateway Watchdog
Gateway faas-netes Watchdog
Gateway Create Swarm Service
Gateway faas-netes Create deployment & service
Invoke
Deploy
fprocess
fprocess

Zero to Serverless - OpenFaaS at the Open Source Summit