Fn Project Helm Chart for Kubernetes

We are proud to announce the release of our Helm Chart for the Fn Project. Helm is a CLI tool that serves as a package manager for Kubernetes. Charts are packages of pre-configured Kubernetes resources.

The Fn Helm Chart consists of the following components:

  • Fn service (API)
  • Fn UI
  • Flow service (API)
  • Flow UI

Note: If you haven’t already read about Fn Flow, I highly recommend taking a look at the Flow 101 and Flow 102 blog posts.


Here are some of the core design principals behind this project:

Simplified deployment and administration
Fn consists of several components, each of which are configurable to some degree. This tends to lead to cognitive overload, when really we just want to make the developer experience solid from the start. With Helm, we apply our basic configuration to the chart’svalues.yaml, so all configuration is tied to a single file.

Deployable to any Kubernetes cluster & cloud agnostic
Fn is inherently cloud agnostic, so the Helm Chart should be no different. The only requirement is a Kubernetes cluster. The chart should be deployable to any compute infrastructure that meets this need, whether it be in the cloud, on-premise, or on your laptop running minikube.

Open source
Consistent with the open source strategy for Fn, we want to share the chart with the community. We will be submitting to the official Kubernetes charts repository shortly; initially to the incubator, then to stable upon approval.


How to get Fn started with Helm

This guide will walk through how to deploy the Fn Helm Chart to Kubernetes and how to write your first function. For this example we will be using minikube.

Requirements:

  1. minikube — refer to the official docs for your OS
  2. Helm
  3. Fn CLI

Getting set up with minikube

Start up a VM with minikube:

minikube start --kubernetes-version=v1.7.0

Initialize Helm by installing Tiller, the server portion of Helm.

helm init

Installing the Fn Helm Chart

Clone the fn-helm repo if you haven’t already (https://github.com/fnproject/fn-helm):

git clone git@github.com:fnproject/fn-helm.git && cd fn-helm

Install chart dependencies (MySQL, Redis):

helm dep build fn

To install the chart with the release name my-release:

The output of helm install will show the commands to run (depending on the service type) to configure the FN_API_URL as needed in the following step.

Note: if you do not pass the --name flag, a release name will be auto-generated. You can view releases by running helm list (or helm ls, for short).

Configure Fn CLI

Required environment variables:

  1. FN_API_URL- See the output of helm install for how to set this.
  2. FN_REGISTRY - Set to your Docker Hub username, or the FQDN of a private registry. e.g. export FN_REGISTRY=bobloblaw

Writing your function

For this example, we’ll be writing a simple Hello World function in Go.

See our Getting Started Series for how to get started writing functions in your favorite language.

First, create a new directory for the function:

mkdir hello-go && cd $_

The following is a simple Go program that outputs a string to STDOUT. Copy and paste the code below into a file called func.go:

Initialize the function. This detects the runtime from the file extension (.go) and creates a func.yaml:

$ fn init
Found go function, assuming go runtime.
func.yaml created.

Let’s take a look at our func.yaml:

$ cat func.yaml
version: 0.0.1
runtime: go
entrypoint: ./func

Test the function locally:

fn run

You should see it output Hello from Fn!.

Next, let’s deploy the function to the Fn server:

fn deploy --app myapp

The deploy command also creates a route on the Fn server, in this case /hello-go, which is the name of the directory created in step 1.

We can verify this by running the following command:

$ fn routes list myapp
path image endpoint
/hello-go bobloblaw/hello-go:0.0.2 192.168.99.100:32615/r/myapp/hello-go

Lastly, call the function we just deployed:

fn call myapp /hello-go
# or via curl
curl 192.168.99.100:32615/r/myapp/hello-go
# or in a browser
http://192.168.99.100:32615/r/myapp/hello-go

That’s it! You just deployed your first function and called it. To update your function you can update your code and run fn deploy myapp again.

What’s Next

  • Add Fn LB support to enable intelligent routing of functions within a Kubernetes cluster.
  • Add ability to enable metrics: Prometheus, Grafana.
  • Eventually get added to Kubernetes Stable Charts.

Questions?

Like what you read? Give Derek Schultz a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.