Web701 10

April 1, 2019
Web701 VirtualBox Serverless OpenFaas Docker CLI Python

Web Development 701 ~ OpenFaas Continued ~ Lab 3

In this blog we are going to explore the OpenFaas workshop. Since we already have OpenFaas deployed and running from the previous blog, we are going to skip to lab 3; introduction to functions. OpenFaas provides two ways of creating a new function; using a template, or using an existing binary. I dont have a binary to use, so I am going to be using a template.

To start we have to pull the templates from github via the following.

faas-cli template pull


Next to create a hello world function in Python via the following.

faas-cli new --lang python3 hello-openfaas --prefix="oglinuk"

The tutorial suggests to edit the handler.py file and to replace the return value with something else, so I changed it to return Hello from OpenFaas!.

Next we run the following command.

faas-cli up -f hello-openfaas.yml

We can invoke our function two ways.

  1. Going to localhost:8080/function/hello-openfaas
  2. Executing the command echo | faas-cli invoke hello-openfaas

The next step in the tutorial is to output the container logs which can be done via the following.

docker service logs -f hello-openfaas

The tutorial goes on to cover verbose output with write_debug, multiple functions, custom templates, and custom binaries as functions which I am not going to cover but have provided a link in case you would like to explore.

Web701 22

June 15, 2019
Web701 Serverless OpenFaas Docker CLI Python Digital Ocean

Web701 21

May 21, 2019
Web701 VirtualBox Serverless OpenFaas Docker CLI Python

Web701 20

May 20, 2019
Web701 Python Django Heroku Web Hosting
comments powered by Disqus