Getting started with OpenFaaS on minikube

Alex Ellis
Nov 18, 2017 · 6 min read

This is a guide on how to setup OpenFaaS — Serverless Functions Made Simple on Kubernetes 1.8 or later with minikube. minikube is a Kubernetes distribution which lets you run a Kubernetes cluster on your laptop — it’s available for Mac and Linux, but is most commonly used with MacOS.

OpenFaaS in 2021:

Quite a lot has changed since this blog post was written. KinD, Multipass and K3d all provide light-weight alternatives to local Kubernetes. Minikube is no longer the only option.

Please try one of the following:

Image for post
Image for post

Getting set up with Minikube on MacOS

  1. Install minikube if you don’t already have it on your system.
  2. Install the xhyve driver or VirtualBox which will be used to create a Linux VM for minikube. I find the VirtualBox option to be the most reliable.
  3. Setup minikube using the official docs — make sure that you enable RBAC, too.
  4. Install faas-cli using curl -sL | sudo sh or brew
  5. Install the helm CLI via brew: brew install kubernetes-helm
  6. Start a local cluster: minikube start

Deploy OpenFaaS to minikube

  1. Create namespaces for OpenFaaS core components and OpenFaaS Functions: kubectl apply -f
  2. Add the OpenFaaS helm repository: helm repo add openfaas
  3. Update all the charts for helm: helm repo update
  4. Generate a random password: export PASSWORD=$(head -c 12 /dev/urandom | shasum| cut -d' ' -f1)
  5. You may want to take a note of your password with echo $PASSWORD before continuing.
  6. Create a secret for the password kubectl -n openfaas create secret generic basic-auth --from-literal=basic-auth-user=admin --from-literal=basic-auth-password="$PASSWORD"
  7. Install OpenFaaS using the chart: helm upgrade openfaas --install openfaas/openfaas --namespace openfaas --set functionNamespace=openfaas-fn --set basic_auth=true
  8. Set the OPENFAAS_URL env-var export OPENFAAS_URL=$(minikube ip):31112
  9. Finally once all the Pods are started you can login using the CLI: echo -n $PASSWORD | faas-cli login -g http://$OPENFAAS_URL -u admin — password-stdin

You’ll now see the OpenFaaS pods being installed on your minikube cluster. Type in kubectl get pods -n openfaas to see them:

NAME                            READY     STATUS    RESTARTS   AGEalertmanager-6dbdcddfc4-fjmrf   1/1       Running   0          1mfaas-netesd-7b5b7d9d4-h9ftx     1/1       Running   0          1mgateway-965d6676d-7xcv9         1/1       Running   0          1mprometheus-64f9844488-t2mvn     1/1       Running   0          1m

If you run into any issues you can follow the troubleshooting guide for Kubernetes with OpenFaaS or the helm installation guide.


The API Gateway contains a minimal UI for testing functions and exposes a RESTful API for function management. The faas-netesd daemon is a Kubernetes controller which connects to the Kubernetes API server to manage Services, Deployments and Secrets.

Prometheus and AlertManager work in tandem to enable auto-scaling of functions to match demand. Prometheus metrics give you operational oversight and allow you to build powerful dashboards.

Prometheus dashboard example:

Image for post
Image for post

To get your own Grafana dashboard, see the OpenFaaS workshop at the end of the post.


OpenFaaS uses the Docker image format for the creation and versioning of functions which means that unlike many other FaaS projects you can use this in production to do:

  • vulnerability scanning
  • CI/CD
  • rolling upgrades

You can also deploy OpenFaaS to your existing production cluster and make use of spare capacity. The core services require around 10–30MB of RAM each.

Scaffold a new function

faas-cli new --lang python3 hello

This will create hello.yml along with a handler folder containing your file and requirements.txt for any pip modules you may need. You can edit these at any time without worrying about maintaining a Dockerfile — we do that and use best practices:

  • multi-stage builds
  • non-root users
  • Official Docker Alpine Linux builds for the base (this is swappable)

Build your function

Your function will be built on your local machine and then pushed to a Docker registry. Let’s use the Docker Hub — just edit the hello.yml file and enter your user account name:

provider:  name: faas  gateway:  hello:    lang: python3    handler: ./hello    image: alexellis2/hello

Now invoke a build. You will need Docker on your local system.

faas-cli build -f hello.yml

Push the versioned Docker image which contains your function up to the Docker Hub. If you’ve not logged into the Docker hub then type in docker login before carrying on.

faas-cli push -f hello.yml

Once you have multiple functions you can use the --parallel=N flag to build or push with multiple cores at once. The CLI also supports options such as --no-cache and --squash.

Deploy and test your function

Now you can deploy your function, see it listed and invoke it. Each time you invoke the function we collect metrics which are made available through Prometheus.

$ export gw=http://$(minikube ip):31112$ faas-cli deploy -f hello.yml --gateway $gw
Deploying: hello.
No existing function to removeDeployed.URL:

You are given a standard route for invoking the function in the deployment message, but can also use the CLI to save on typing:

$ echo test | faas-cli invoke hello --gateway $gw

Now list the functions deployed and you will see the invocation count has gone up.

$ faas-cli list --gateway $gw
Function Invocations Replicas
hello 1 1

Note: this command also accepts a --verbose flag for more information.

Since we are running OpenFaaS on a remote cluster (a Linux VM) we set up a --gateway override environmental variable. This could also be a remote host on a cloud platform. The alternative is to update the gateway value in your .yml file.

Moving beyond minikube

Once you are familiar with OpenFaaS on minikube you can deploy to any Kubernetes cluster running on Linux hosts. Here’s an example of OpenFaaS running on Kubernetes on Google’s GKE platform by Stefan Prodan of WeaveWorks demonstrating the built-in auto-scaling capabilities:

We’ve tested OpenFaaS with many different managed Kubernetes services — you can find instructions in the Kubernetes Deployment Guide.

Keep learning

We have dozens of guides and blog available to get you up and running on the “FaaS Train” — head over to GitHub and bookmark our guides:

I’ve included a short 15min video from Dockercon 2017 in Copenhagen where I gave an overview of Serverless and OpenFaaS at the Moby Summit.

  • For all the latest hacks, demos and news follow OpenFaaS on Twitter
  • To go deeper with Serverless Functions — try the OpenFaaS Workshop — a dozen self-paced hands-on labs to help you master functions.
  • Having problems with Minikube? Try OpenFaaS with KinD — a new lighter-weight alternative that will run anywhere you have Docker.

Written by Alex Ellis, the founder of OpenFaaS.

Thanks to Richard Gee for proof-reading this post.

Image for post
Image for post

Join our community Slack and read our weekly Faun topics ⬇

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author! ⬇


The Must-Read Publication for Creative Developers & DevOps Enthusiasts

Sign up for FAUN


Medium’s largest and most followed independent DevOps publication. Join thousands of aspiring developers and DevOps enthusiasts Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Alex Ellis

Written by

CNCF Ambassador. OpenFaaS & Inlets founder —



The Must-Read Publication for Creative Developers & DevOps Enthusiasts. Medium’s largest DevOps publication.

Alex Ellis

Written by

CNCF Ambassador. OpenFaaS & Inlets founder —



The Must-Read Publication for Creative Developers & DevOps Enthusiasts. Medium’s largest DevOps publication.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app