Setting up OpenFaaS with minikube

This article is actually an excerpt from here. Some people asked me to separate it, since it can actually serve as a reference for other articles (not just mine).

OpenFaaS is definitely a great option if you’re planning to move into the serverless world.

There are a multitude of options to install and run OpenFaaS, including faasd or managed kubernetes clusters with cloud providers such as Azure, Google or AWS. For the sake of simplicity, today we’ll be using minikube.

Arkade

Arkade is a great tool developed by the OpenFaaS community that greatly simplifies how we install helm charts into a kubernetes cluster. We can also use it to download a variety of CLI tools, such as kubectl, helm and even minikube. We’re going to use it here.

$ arkade get minikube$ arkade get kubectl

Now let’s start our minikube cluster.

$ minikube start
...
Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

If it fails to start, see the minikube drivers page for help. If all goes well, our cluster is ready and we can use kubectl to interact with it.

$ kubectl get pods -A

OpenFaaS

At this point, I will assume kubectl is pointing to the minikube cluster. So, let’s install OpenFaaS with Arkade.

$ arkade install openfaas

To verify that OpenFaaS has started, we use the following command, as suggested by the installation script.

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

Next, we need to install faas-cli. We can do that with Arkade as well.

$ arkade get faas-cli

And then, as suggested by the OpenFaaS installation script, we forward the gateway. This requires the gateway to be deployed, so we can check that first.

$ kubectl rollout status -n openfaas deploy/gateway
deployment "gateway" successfully rolled out
$ kubectl port-forward -n openfaas svc/gateway 8080:8080 &
Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080

Next, we login with faas-cli into the OpenFaaS gateway. Again, as suggested by the installation script.

$ 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
Calling the OpenFaaS server to validate the credentials…
Handling connection for 8080
WARNING! Communication is not secure, please consider using HTTPS. Letsencrypt.org offers free SSL/TLS certificates.
credentials saved for admin http://127.0.0.1:8080

That’s it! Our OpenFaaS cluster is ready to use.

Make sure you clap if you liked it and feel free to leave a comment.