Deploy openfaas on Azure AKS using Helm

openfaas (Functions as a Service) is a framework for building serverless functions with Docker and Kubernetes which has first class support for metrics. Any process can be packaged as a function enabling you to consume a range of web events without repetitive boiler-plate coding.

I was impressed that I managed to get this all setup and working in less than 10 minutes (If we forget that AKS took almost 20 minutes to provision!)

Prerequisites

In order to complete the steps within this article, you need a basic understanding of Kubernetes & the following.

  • An Azure subscription
  • A working installation of Kubectl (tutorial here)
  • A working installation of Helm (see here)
  • Install the openfaas CLI. See the openfaas CLI documentation for options.
  • Azure CLI installed on your development system.
  • Git command-line tools installed on your system.
Deploy the cluster with the Azure CLI

 

1) Install the official latest version of Azure CLI

2) Login to your subscription:

az login

Optional: If you have multiple subscriptions linked to your account, remember to select the one on which you want to work. (az account set -s subscription-id)

3) Create the resource group in which you want to deploy the cluster (in the example ghostinthewiresk8sRG is the name of the Resource Group and westeurope is the chosen location):

az group create -l westeurope -n ghostinthewiresk8sRG

4) Finally, create your cluster. This will create a default cluster with one master and three agents (each VM is sized, by default, as a Standard_D2_v2 with 2vCPUs and 7GiB of RAM):

az acs create –orchestrator-type Kubernetes -g ghostinthewiresk8sRG -n k8sCluster -l westeurope –generate-ssh-keys

Optional: you can specify the agent-count, the agent-vm-size and a dns-prefix for your cluster:

–agent-count 2 –agent-vm-size Standard_A1_v2 –dns-prefix k8sghost

5) Get your cluster credentials ready for kubectl:

az acs kubernetes get-credentials -n k8sCluster -g ghostinthewiresk8sRG

GET OPENFAAS

 

1) Check if the kubectl configuration is ok and if your cluster is up-and-running:

kubectl cluster-info

 

 

Deploy OpenFaaS to the newly created AKS Cluster

Please follow the instructions as per the official docs with Helm. Please ensure you use the basic auth as outlined in the steps.

validate openfaas install

A public IP address is created for accessing the openfaas gateway. To retrieve this IP address, use the kubectl get service command. It may take a few minutes for the IP address to be assigned to the service, until then it will show as pending:

kubectl get service -l component=gateway –namespace openfaas

 

 

To test the openfaas system, browse to the external IP address on port 8080, http://13.69.84.16:8080 in this example:

 

 

 

 

 

 

 

 

 

Create first function

Now that openfaas is operational, you could create a function using the OpenFaaS portal but I will show you how to do it via the CLI.

1) In order to see what Functions are available in the store type:

faas-cli store list

2) We are going to use Figlet to Generate ascii logos through the use of a binary. To install run the following:

faas-cli store deploy figlet –gateway http://13.69.84.16:8080

Use curl to invoke the function. Replace the IP address in the following example with that of your openfaas gateway:

curl -X POST http://13.69.84.16:8080/function/figlet -d “ghostinthewire5”

If you made it this far and now have a working deployment of openfaas on AKS — congratulations! Try out a bunch of functions from the store, or use the openfaas CLI Tool to build your own functions and deploy them.

Hope this was helpful!

I was amazed by how quick I managed to get this simple demo configured. I only have a little experience of Kubernetes and was able to get this working in less than 10 minutes (When you consider AKS took almost double the time to provision), which is awesome considering all the complexity this abstracts away from you.

Another big part of this demo that hasn’t been mentioned is the incredible support I received from the Founder Alex Ellis and the very active OpenFaaS community.

For help with OpenFaaS please visit the OpenFaaS community sign-up page.

Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *