Hands-on labs: Serverless and OpenFaaS with Python
Switch branches/tags
Clone or download
rgee0 and alexellis Add images pre-pull command to lab 1
Experience has shown that multiple attendees trying to download the system imagesduring the workshop can be temperamental where the establishments WiFi is under high load.  This change introduces a pre-pull command to lab 1 that attendees should run prior to attending.  The pre-reqs preamble in the README has also been changed to further emphasize that the pre-reqs/lab 1 should be addressed prior to attending.

Signed-off-by: Richard Gee <richard@technologee.co.uk>
Latest commit 555bb83 Dec 8, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
astronaut-finder Convert remaining print() statements to return May 11, 2018
diagram Add diagram to lab 7 Mar 2, 2018
hello-openfaas Convert remaining print() statements to return May 11, 2018
hmac-protected Add small fixes to lab6 and lab11 Nov 10, 2018
issue-bot-secrets Update secret path Jun 26, 2018
issue-bot Fix couple of misleading and outdated secrets paths Jul 16, 2018
screenshot Added an link back to the end of lab8 Apr 8, 2018
translations/ja Initial Japanese version of the OpenFaaS workshop Oct 13, 2018
.DEREK.yml Redirect Derek file to openfaas/faas file Jun 16, 2018
.gitignore Initial Jan 21, 2018
LICENSE Initial Jan 21, 2018
README.md Add images pre-pull command to lab 1 Dec 16, 2018
appendix.md Fixed improvements pointed out. Apr 3, 2018
astronaut-finder.yml Add part 1 of Lab 6, rename space-counter function Mar 1, 2018
hello-openfaas.yml Add topics and update lab3 Feb 26, 2018
lab1.md Add images pre-pull command to lab 1 Dec 16, 2018
lab10.md Fix index page Nov 7, 2018
lab11.md Add small fixes to lab6 and lab11 Nov 10, 2018
lab2.md Move to new sample name format Jun 7, 2018
lab3.md Update with `faas-cli up` Sep 28, 2018
lab4.md Update lab typo Nov 22, 2018
lab5.md Fix spelling mistake in lab5 Nov 22, 2018
lab6.md Add small fixes to lab6 and lab11 Nov 10, 2018
lab7.md Link to full list of callback headers Oct 21, 2018
lab8.md Small change of lab8 to clarify error Oct 1, 2018
lab9.md Add scale from zero to Lab 9 Nov 21, 2018



This is a self-paced workshop for learning how to build, deploy and run OpenFaaS functions.


This workshop starts by deploying OpenFaaS to your laptop with Docker for Mac or Windows and then shows how to build, deploy and invoke Serverless functions in Python. Topics will include: managing dependencies with pip, dealing with API tokens through secure secrets, monitoring functions with Prometheus, invoking functions asynchronously and chaining functions together to create applications. We finish by creating a GitHub bot which automatically respond to issues. The same method could be applied by connecting to online event-streams through IFTTT.com - this will enable you to build bots, auto-responders and integrations with social media and IoT devices.


We walk through how to install these requirements in Lab 1. Please do Lab 1 before you attend an instructor-led workshop. At the very least you should install Docker and pre-pull the OpenFaaS images.

  • Functions will be written in Python, so prior programming or scripting experience is preferred
  • Install the recommended code-editor / IDE VSCode
  • For Windows install Git Bash
  • Preferred OS: MacOS, Windows 10 Pro/Enterprise, Ubuntu Linux


  • Docker CE for Mac/Windows Edge edition
  • Docker CE for Linux

Note: As a last resort if you have an incompatible PC you can run the workshop on https://labs.play-with-docker.com/.

Instructor-led workshops

If you're taking an instructor-led workshops then a link will be shared to join the OpenFaaS Slack community. Use the designated channel for the workshop to discuss comments, questions and suggestions.

Lab 1 - Prepare for OpenFaaS

  • Install pre-requisites
  • Set up a single-node cluster with Docker Swarm
  • Docker Hub account
  • OpenFaaS CLI
  • Deploy OpenFaaS

Lab 2 - Test things out

  • Use the UI Portal
  • Deploy via the Function Store
  • Learn about the CLI
  • Find metrics with Prometheus

Lab 3 - Introduction to Functions

  • Scaffold or generate a new function
  • Build the astronaut-finder function
  • Add dependencies with pip
  • Troubleshooting: find the container's logs
  • Troubleshooting: verbose output with write_debug
  • Use third-party language templates

Lab 4 - Go deeper with functions

Lab 5 - Create a Gitbot

Build issue-bot - an auto-responder for GitHub Issues

  • Get a GitHub account
  • Set up a tunnel with ngrok
  • Create an webhook receiver issue-bot
  • Receive webhooks from GitHub
  • Deploy SentimentAnalysis function
  • Apply labels via the GitHub API
  • Complete the function

Lab 6 - HTML for your functions

  • Generate and return basic HTML from a function
  • Read and return a static HTML file from disk
  • Collaborate with other functions

Lab 7 - Asynchronous Functions

  • Call a function synchronously vs asynchronously
  • View the queue-worker's logs
  • Use an X-Callback-Url with requestbin and ngrok

Lab 8 - Advanced Feature - Timeouts

  • Adjust timeouts with read_timeout
  • Accommodate longer running functions

Lab 9 - Advanced Feature - Auto-scaling

  • See auto-scaling in action
    • Some insights on min and max replicas
    • Discover and visit local Prometheus
    • Execute and Prometheus query
    • Invoke a function using curl
    • Observe auto-scaling kicking in

Lab 10 - Advanced Feature - Secrets

  • Adapt issue-bot to use a secret
    • Create a Swarm secret
    • Access the secret within the function

You can start with the first lab Lab 1.

Lab 11 - Advanced feature - Trust with HMAC

  • Apply trust to functions using HMAC

Tear down / Clear up

You can find how to stop and remove OpenFaaS here

Wrapping up

If you're taking an instructor-led workshop, we'll now take Q&A and cover some advanced topics:

  • Auto-scaling
  • Security
    • TLS / Basic Authentication
  • Object storage
  • Customisations for templates

The appendix contains some additional content.


Thanks to @iyovcheva, @BurtonR, @johnmccabe, @laurentgrangeau, @stefanprodan, @kenfdev, @templum & @rgee0 for contributing to, testing and translating the labs.