Difficulty: Introduction
Estimated Time: 20 minutes

OpenFaaS on Kubernetes

OpenFaaS 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.

Key Features

  • Ease of use through UI portal and one-click install
  • Write functions in any language for Linux or Windows and package in Docker/OCI image format
  • Portable - runs on existing hardware or public/private cloud
  • Kubernetes and Docker Swarm native
  • CLI available with YAML format for templating and defining functions
  • Scales as demand increases

You will learn how:

  • to install OpenFaaS on Kubernetes
  • to interact with OpenFaaS from the command line and its portal
  • functions are deployed and removed
  • functions are named, exposed, and invoked
  • functions are listed, inspected and monitored
  • functions automatically scale up and down based on load

The OpenFaaS architecture is described in the OpenFaaS documentation. More references to documentation and examples listed at the end of this scenario.

Conclusion

OpenFaaS is an independent project created by Alex Ellis that is being built and shaped by a growing community of contributors. Kubernetes provides this serverless framework a resilient and scalable cluster where OpenFaaS can compliment other solutions in the same shared data center.

Lessons Learned

With these steps you have learned:

  • how to install OpenFaaS on Kubernetes,
  • how to interact with OpenFaaS from the command line and its portal,
  • how functions are deployed and removed,
  • how functions are named, exposed, and invoked,
  • how functions are listed, inspected and monitored,
  • how functions automatically scale up and down based on load.

References

* Faas-netes chart versus OpenFaaS Operator chart The faas-netes controller is the most tested, stable and supported version of the OpenFaaS integration with Kubernetes. In contrast the OpenFaaS Operator (used in this scenario) is based upon the codebase and features from faas-netes, but offers a tighter integration with Kubernetes through CustomResourceDefinitions (CRD). This means you can type in kubectl get functions to list the CRD that make this Kind: function possible.


No Fluff Just Stuff

For a deeper understanding of these topics and more join me, Jonathan Johnson, for a transcendent experience on the No Fluff Just Stuff Software Symposium Tour.

OpenFaaS

Step 1 of 10

Your Kubernetes Cluster

For this scenario, Katacoda has just started a fresh Kubernetes cluster for you. Verify it's ready for your use.

kubectl version --short && kubectl cluster-info && kubectl get nodes

The Helm package manager used for installing applications on Kubernetes is also available.

helm version --short

Kubernetes Dashboard

You can control the cluster with the kubectl CLI tool or through the Kubernetes Dashboard. Because the dashboard can be accessed publicly, it is protected and requires the secret access token to sign in. Copy the token from this secret.

export TOKEN=$(kubectl describe secret $(kubectl get secret | awk '/^dashboard-token-/{print $1}') | awk '$1=="token:"{print $2}') && echo -e "\n--- Copy and paste this token for dashboard access --\n$TOKEN\n---"

To access the dashboard, click on the Kubernetes Dashboard tab above the command line or from this link: https://[[HOST_SUBDOMAIN]]-30000-[[KATACODA_HOST]].environments.katacoda.com/. At the sign in prompt select Token and paste in the token, you copied a moment ago.

For Kubernetes clusters exposed to the public, always lock administration access including access to the dashboard.

Terminal
Kubernetes Dashboard
OpenFaaS Portal
Grafana
Prometheus
Alerts