Installing OpenFaaS On k3s (Single Node)

If you have ever got your hands on Azure Function or on AWS Lambda, then you might be familiar with the concept of serverless computing. So in order to test the concept of a function (serverless function), we have to have an Azure or an AWS account. The SDK from both the platforms allow you to build, develop and test the functions on your local development machine, but when it comes to production environment, you again have to turn yourself to Azure or AWS for hosting it. OpenFaaS is an open-source product developed by Alex Ellis which help developers to deploy event-driven functions, time triggered and microservices to Kubernetes without repetitive, boiler-plate coding. Let’s see how we can deploy OpenFaas on Ubuntu 20.04 LTS using k3s. You can also make use of another Kubernetes flavour which suites your needs.

Installing k3s

I am making use of Lightweight Kubernetes also known as k3s. This is a certified Kubernetes distribution built for IoT and Edge computing.

$ curl -sfL | sh -

Installing k3s

After the installation is completed, you can check if the k3s service is running by executing the below command.

$ sudo systemctl status k3s

Check k3s service status

Install faas-cli

faas-cli is a command line utility which let you work with OpenFaaS.

$ curl -sL | sudo sh

Installing OpenFaaS CLI

Installing arkade

Arkade is a Kubernetes app installer. It allows you to install apps and charts to your cluster in one command. The official documentation of OpenFaaS states that using arkade is the fastest option. If you wish you can also make use of Helm to install but as I am installing it on a single node machine, I will stick with arkade option.

Run the below command to download and install it.

$ curl -SLsf | sudo sh

Installing Arkade

Installing OpenFaaS

Installing OpenFaaS with arkade is extremely simple and you can get the installation done by executing this command:

$ arkade install openfaas

This should install OpenFaaS but unfortunately on my machine this results into an error. Below are the two screenshots that I took when I got this error. The first screenshot says there is a permission error in /etc/rancher/k3s/k3.yaml. For the resolution of this error, I changed the permission on the file to 744 and the error goes away.

Installing Arkade - Error 1

If you scroll down to the end of the command you will notice that there is another error which states that Kubernetes cluster unreachable.

Installing Arkade - Error 2

Even knowing that k3s service is up and running I was not able to figure out what could be a problem. So I searched the web and found this issue thread on Github in which one of the commenters were able to fix this error by running the below command.

$ kubectl config view --raw > ~/.kube/config

I tried this installation on Raspberry PI 4 running Raspbian buster x64 and there as well I saw these error messages.

After this, you can run the installation of OpenFaaS using arkade again and this time it should be successfull. Here is the output on my system after the installation was successfull.

prashant@ubuntu:~$ arkade install openfaas
Using Kubeconfig: /etc/rancher/k3s/k3s.yaml
Using kubeconfig: 
Node architecture: "amd64"
Client: "x86_64", "Linux"
2021/01/04 08:34:42 User dir established as: /home/prashant/.arkade/
Using Kubeconfig: 
[Warning] unable to create secret basic-auth, may already exist: Error from server (AlreadyExists): secrets "basic-auth" already exists
"openfaas" has been added to your repositories

VALUES values.yaml
Command: /home/prashant/.arkade/bin/helm [upgrade --install openfaas openfaas/openfaas --namespace openfaas --values /tmp/charts/openfaas/values.yaml --set clusterRole=false --set operator.create=false --set gateway.replicas=1 --set queueWorker.replicas=1 --set basic_auth=true --set serviceType=NodePort --set gateway.directFunctions=true --set openfaasImagePullPolicy=IfNotPresent --set faasnetes.imagePullPolicy=Always --set basicAuthPlugin.replicas=1 --set ingressOperator.create=false --set queueWorker.maxInflight=1]
Release "openfaas" does not exist. Installing it now.
NAME: openfaas
LAST DEPLOYED: Mon Jan  4 08:34:45 2021
NAMESPACE: openfaas
STATUS: deployed
To verify that openfaas has started, run:

  kubectl -n openfaas get deployments -l "release=openfaas, app=openfaas"
= OpenFaaS has been installed.                                        =

# Get the faas-cli
curl -SLsf | sudo sh

# Forward the gateway to your machine
kubectl rollout status -n openfaas deploy/gateway
kubectl port-forward -n openfaas svc/gateway 8080:8080 &

# If basic auth is enabled, you can now log into your gateway:
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)
echo -n $PASSWORD | faas-cli login --username admin --password-stdin

faas-cli store deploy figlet
faas-cli list

# For Raspberry Pi
faas-cli store list \
 --platform armhf

faas-cli store deploy figlet \
 --platform armhf

# Find out more at:

Thanks for using arkade!

The output contains important information which we need to get started with faas-cli and OpenFaaS. As we have already install faas-cli, we will now need to forward the gateway to the machine.

First we will check the rollout status of the gateway by issuing the below command:

$ kubectl rollout status -n openfaas deploy/gateway

Checking roolout status of gateway deployment

The above command should state that it is successfull. After this we can forward the gateway to the machine.

$ kubectl port-forward -n openfaas svc/gateway 8080:8080 &

Port Forwarding

The & sign in the end of the command will execute it in the background. You can type in jobs to check the status of the job.

We also need to check if the deployment is in ready state or not. To check the deployment state execute the command:

$ kubectl get deployments -n openfaas -l "release=openfaas, app=openfaas"

Post installation openfaas - check deployment

If any of the app deployed is not ready, you should be able to see it now. Check the READY column in the command output and you should see something 0/1. This would mean that the deployment is not ready and you should check back in sometime. Once you have the output like the one in the screenshot above, you are good to go.

Now the last step is to acquire the password for OpenFaaS UI which we will use to manage OpenFaaS. To do that execute the below command:

$ PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)
echo -n $PASSWORD | faas-cli login --username admin --password-stdin

Get password for OpenFaaS UI

You can then view the password by printing the value of the PASSWORD variable using the echo command.


Copy and save the password securely.

Now let’s try accessing the OpenFaaS UI (OpenFaaS Portal) by navigating to the http://localhost:31112/ui or by using the IP address of machine instead of localhost if you are accessign it from another machine on your network.

Login prompt for OpenFaaS Portal

Username is set to admin by default and the password is the one which you saved in the above step.

Click on the Deploy New Function link located at the center of the home page or at the left side bar. You will be able to see the list of the different functions which you can deploy by just selecting the function from the list and then clicking the Deploy button at the bottom of the dialog.

Note that the list of functions that you see in the Deploy new Function dialog will be different on Raspberry PI as OpenFaaS will only list the functions which are available for the platform on which it is running.

comments powered by Disqus