• Stars
    star
    955
  • Rank 47,869 (Top 1.0 %)
  • Language
    Python
  • License
    MIT License
  • Created about 7 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Learn Serverless for Kubernetes with OpenFaaS

The openfaas-workshop was written in 2017/2018, however more appropriate and recent materials now exist:

openfaas-workshop

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

In this workshop you begin by deploying OpenFaaS to your laptop or a remote cluster with Docker for Mac or Windows. You will then kick the tires with the OpenFaaS UI, CLI and Function Store. After building, deploying an invoking your own Serverless Functions in Python you'll go on to cover topics such as: 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. The labs culminate by having you create your very own GitHub bot which can respond to issues automatically. 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.

Finally the labs cover more advanced topics and give suggestions for further learning.

Translations

Learn for free, show your appreciation as a GitHub Sponsor

OpenFaaS along with these materials are provided for free and require time and effort to maintain.

Requirements:

We walk through how to install these requirements in Lab 1. Please do Lab 1 before you attend an instructor-led workshop.

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

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

Pick your track

In Lab 1 you will pick your track and then throughout the labs look out for any special commands needed for the container orchestrator for your track.

Kubernetes

You can also learn about Serverless on Kubernetes using OpenFaaS.

The recommendation from the OpenFaaS community is that you run Kubernetes in production, but all the knowledge you can is transferrable and functions do not have to be rebuilt.

Lab 1 - Prepare for OpenFaaS

  • Install pre-requisites
  • Set up a single-node cluster with Kubernetes
  • 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 custom and third-party language templates
  • Discover community templates using the Template Store

Lab 4 - Go deeper with functions

Lab 5 - Create a GitHub bot

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 Kubernetes secret with faas-cli
    • Access the secret within the function

Lab 11 - Advanced feature - Trust with HMAC

  • Apply trust to functions using HMAC

You can start with the first lab Lab 1.

Tear down / Clear up

You can find how to stop and remove OpenFaaS here

Next steps

If you're in an instructor-led workshop and have finished the labs you may want to go back through the labs and edit/alter the code and values or carry out some of your own experiments.

Here are some ideas for follow-on tasks / topics:

OpenFaaS Cloud

Try the multi-user, managed experience of OpenFaaS - either on the Community Cluster, or by hosting your own OpenFaaS Cloud.

TLS

CI/CD

Setup Jenkins, Google Cloud Build or GitLab and build and deploy your own functions using the OpenFaaS CLI:

Storage / databases

Instrumentation / monitoring

Additional blog posts and tutorials

Appendix

The appendix contains some additional content.

Acknowledgements

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

More Repositories

1

faas

OpenFaaS - Serverless Functions Made Simple
Go
24,942
star
2

faasd

A lightweight & portable faas engine
Go
2,550
star
3

faas-netes

Serverless Functions For Kubernetes
Go
2,122
star
4

faas-cli

Official CLI for OpenFaaS
Go
794
star
5

openfaas-cloud

The Multi-user OpenFaaS Platform
Go
767
star
6

templates

OpenFaaS Classic templates
Dockerfile
261
star
7

of-watchdog

Reverse proxy for STDIO and HTTP microservices
Go
244
star
8

ofc-bootstrap

Bootstrap OpenFaaS Cloud for your team
Go
181
star
9

store

Official Function and Template Store for OpenFaaS
Shell
162
star
10

faas-provider

A backend provider interface for OpenFaaS
Go
123
star
11

nats-queue-worker

Queue-worker for OpenFaaS with NATS Streaming
Go
122
star
12

golang-http-template

Golang templates for OpenFaaS using HTTP extensions
Shell
100
star
13

openfaas-linkerd-workshop

Lightweight Serverless on Kubernetes with mTLS and traffic-splitting with Linkerd2
98
star
14

python-flask-template

HTTP and Flask-based OpenFaaS templates for Python 3
Python
82
star
15

faas-swarm

OpenFaaS provider for Docker Swarm
Go
79
star
16

ingress-operator

Custom domains, paths and TLS for your OpenFaaS Functions
Go
68
star
17

docs

Official Docs for OpenFaaS
65
star
18

community-cluster

OpenFaaS Cloud Cluster for Community
60
star
19

connector-sdk

SDK for connecting events to functions
Go
56
star
20

openfaas.github.io

Primary website / landing-page for the project
HTML
53
star
21

store-functions

Common CLIs packaged in containers with a HTTP interface
Dockerfile
51
star
22

media

Press kit / Media pack for OpenFaaS
44
star
23

cron-connector

Invoke functions on a schedule.
Go
39
star
24

nats-connector

An OpenFaaS event-connector to trigger functions from NATS
Go
38
star
25

mqtt-connector

MQTT connector for OpenFaaS
Go
32
star
26

cloud-functions

OpenFaaS social functions
Python
28
star
27

classic-watchdog

Classic Watchdog for OpenFaaS
Go
25
star
28

certifier

OpenFaaS Compliance testing
Go
25
star
29

license-check

Check your code for Copyright header compliance
Go
19
star
30

ruby-http

A Ruby HTTP template for OpenFaaS
Ruby
12
star
31

faas-middleware

HTTP middleware for OpenFaaS
Go
12
star
32

templates-sdk

SDK resources for templates such as models and entrypoints
Java
10
star
33

function-builder-examples

OpenFaaS Pro function builder API examples
PHP
10
star
34

social-functions

Enabling social media for OpenFaaS
Go
9
star
35

cli.openfaas.com

The installation script for the OpenFaaS CLI served by Netlify
Shell
9
star
36

python-fan-in-example

Python code example for implementing a fan-out/fan-in pattern with OpenFaaS functions.
Python
8
star
37

config-checker

Check your OpenFaaS Configuration
Go
7
star
38

astradb-openfaas

Connect to Astra DB using Node.js and OpenFaaS
JavaScript
3
star
39

go-sdk

An SDK for use within OpenFaaS functions
Go
3
star
40

openfaas-autoscaler-tests

JavaScript
2
star
41

derek-test-repo

Testing compliance
1
star
42

.github

README for organisation
1
star
43

multi-tenant-tests

Basic multi-tenant-tests
JavaScript
1
star