Rapid first few steps with Fn – open source project for serverless functions image 111

Rapid first few steps with Fn – open source project for serverless functions

Project Fn is an open source project that provides a container native, poly-language, cloud agnostic (aka run on any cloud) serverless platform for running functions. Fn was launched during Oracle OpenWorld 2017. Fn is available on GitHub (https://github.com/fnproject/fn ) and provides all resources required to get started. In this article, I will just show you (and myself) how I went through the quick start steps and what it looked like on my laptop (Windows 10 with Vagrant and VirtualBox).

I simply get Fn up and running, create a first function that I then deploy and access through HTTP. I briefly show the APIs available on the Fn server and Fn UI application.

Steps:

  1. Create VirtualBox VM with Debian and Docker (for me, Ubuntu 14 failed to run Fn; I created issue 437 for that) – this step is described in a different article
  2. Install Fn command line
  3. Install and run Fn server in the VM, as Docker container
  4. Create function hello
  5. Initialize new function and run it
  6. Deploy the new function (in its own Docker Container running inside the container running Fn server)
  7. Invoke the new function over http from the Host laptop
  8. Run the Fn UI application
  9. Inspect the Fn Server REST APIs

Connect into the Debian Virtual Machine – for me with vagrant ssh.

Install Fn Command Line

To install the Fn command line, I used this command:

curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh

image 

Install and run Fn server in the VM, as Docker container

To run the Fn server, after installing the CLI, I just used

fn start

image

Fn Server is running.

Create function hello

As per the instructions in the quick start guide, I created a new directory hello with a text file hello.go:

SNAGHTML2859e5fa

Note: I created these on the host laptop inside the directory that is mapped into the VM under /vagrant. So I can access the file inside the VM in /vagrant/hello.

Initialize new function and run it

image

and after a little while

image

Deploy the new function

(in its own Docker Container running inside the container running Fn server)

image

image

Run function inside Debian VM:

image

Invoke the new function over http from the Host laptop

image

The IP address 192.168.188.102 was assigned during the provisioning of the VM with Vagrant.

Run the Fn UI application

A UI application to inspect all Fn applications and functions can be installed and ran:

image

image

And accessed from the host laptop:

image

Note: for me it did not show the details for my new hello function.

Inspect the Fn Server REST APIs

Fn platform publishes REST APIs that can be used to programmatically learn more about applications and functions and also to manipulate those.

image

Some examples:

image

and

image

Summary

Getting started with Fn is pretty smooth. I got started and wrote this article in under an hour and a half. I am looking forward to doing much more with Fn – especially tying functions together using Fn Flow.

Resources

Fn project home page: http://fnproject.io/

Article to quickly provision VirtualBox Image with Debian and Docker: https://technology.amis.nl/2017/10/19/create-debian-vm-with-docker-host-using-vagrant-automatically-include-guest-additions/

Fn quick start guide: https://github.com/fnproject/fn 

Fn UI on GitHub: https://github.com/fnproject/ui 

Fn API: http://petstore.swagger.io/?url=https://raw.githubusercontent.com/fnproject/fn/master/docs/swagger.yml