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
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’s
values.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.
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.
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.
Installing the Fn Helm Chart
Clone the fn-helm repo if you haven’t already (https://github.com/fnproject/fn-helm):
git clone email@example.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
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
--nameflag, a release name will be auto-generated. You can view releases by running
helm ls, for short).
Configure Fn CLI
Required environment variables:
FN_API_URL- See the output of
helm installfor how to set this.
FN_REGISTRY- Set to your Docker Hub username, or the FQDN of a private registry. e.g.
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
Initialize the function. This detects the runtime from the file extension (.go) and creates a
$ fn init
Found go function, assuming go runtime.
Let’s take a look at our func.yaml:
$ cat func.yaml
Test the function locally:
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
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.
- 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.