OpenFaaS Kubernetes

OpenFaaS ® is an award-winning open source project that makes it easy for developers to deploy applications to Kubernetes in a Serverless-style. Any microservice, API, binary, or function can be packaged and deployed in a very short period of time. Once a workload is deployed via the OpenFaaS CLI, API or UI metrics will be tracked and used to auto-scale your code in response to demand.

OpenFaaS comes with built-in auto-scaling, detailed metrics and queue-processing. You can take advantage of pre-made functions from the Function, or a series of templates for Functions or Microservices covering a wide range of languages such as C#, Java, Go, Ruby, PHP, and more.

Your workloads can be accessed through the OpenFaaS gateway or triggered by a number of event sources such as Kafka, RabbitMQ, Redis and Cron.

The project is built around open interfaces that can be extended easily. Tutorials and guides can help you enable TLS, setup custom domains, CI/CD, OAuth2, multi-user support, and many other features.

You can find out more about OpenFaaS at https://www.openfaas.com/ or take the free workshop online.

Software Included

Package Version License
Prometheus v2.47.2 Apache 2.0
Alertmanager v0.26.0 Apache 2.0
NATS Streaming 0.25.5 Apache 2.0
faas-netes CE 0.17.2 MIT
faas CE 0.27.3 MIT
nats-queue-worker CE 0.14.1 MIT

Creating an App using the Control Panel

Click the Deploy to DigitalOcean button to install a Kubernetes 1-Click Application. If you aren’t logged in, this link will prompt you to log in with your DigitalOcean account.

Deploy to DO

Creating an App using the API

In addition to creating OpenFaaS Kubernetes using the control panel, you can also use the DigitalOcean API. As an example, to create a 3 node DigitalOcean Kubernetes cluster made up of Basic Droplets in the SFO2 region, you can use the following doctl command. You need to authenticate with doctl with your API access token) and replace the $CLUSTER_NAME variable with the chosen name for your cluster in the command below.

doctl kubernetes clusters create --size s-4vcpu-8gb $CLUSTER_NAME --1-clicks openfaas

Getting Started After Deploying OpenFaaS Kubernetes

OpenFaaS has been deployed and is now fully-functioning. During the installation a password was created for your OpenFaaS Gateway along with a LoadBalancer to provide access to your gateway.

OpenFaas does not require doctl, however the below instructions make use of doctl. If you haven’t setup doctl get the doctl binary and run doctl auth.

https://github.com/digitalocean/doctl

Configure kubectl locally

  • Point kubectl to your cluster

In order to start using OpenFaaS, you will need to find your password and LoadBalancer IP. To do this, you will need to use kubectl and point it at your new cluster.

doctl k8s cluster list

f8d01a21-ef2a-4b93-b05f-6774e77a86e5    openfaas-cluster          lon1      1.14.5-do.0    running    openfaas-cluster-default-pool

doctl k8s cluster kubeconfig save openfaas-cluster

Now switch into the context of the cluster:

kubectl config get-contexts
*         do-lon1-openfaas-cluster         do-lon1-openfaas-cluster         do-lon1-openfaas-cluster-admin         

kubectl config set-context do-lon1-openfaas-cluster

Log into OpenFaaS

  • Install the OpenFaaS CLI:
curl -sLSf https://cli.openfaas.com | sudo sh

Note: the CLI is also available via brew install faas-cli

  • Find your LoadBalancer IP:

You can use the LoadBalancer’s IP to log into OpenFaaS, operate the CLI, and to view the UI.

export OPENFAAS_URL=$(kubectl get svc -n openfaas gateway-external -o jsonpath='{.status.loadBalancer.ingress[*].ip}'):8080
echo Your gateway URL is: $OPENFAAS_URL

Note: your DigitalOcean LoadBalancer may take a few minutes to come up, so if you’re not seeing an IP, try again.

  • Get your password
echo $(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode) > password.txt 

echo Your admin password is: $(cat password.txt)
  • Now use the password to authenticate the CLI:
cat password.txt | faas-cli login --username admin --password-stdin

Note: you can use this command at any time to retrieve your password

Check that everything worked

  • Deploy a function
faas-cli store list

# Find one you like

faas-cli store deploy nodeinfo

# List your functions

faas-cli list --verbose

# Check when the function is ready

faas-cli describe nodeinfo

Name:                nodeinfo
Status:              Ready

# Invoke the function using the URL given above, or via `faas-cli invoke`

echo | faas-cli invoke nodeinfo
echo -n "verbose" | faas-cli invoke nodeinfo
  • Try the UI

You can access the UI at the same URL of the gateway, so try this URL:

echo http://$OPENFAAS_URL

Demo of the inception function

Take the wheel

  • Learn OpenFaaS

Now it’s over to you to start learning about Serverless with OpenFaaS and Kubernetes using the hands-on workshop.

https://github.com/openfaas/workshop

  • Add TLS for your OpenFaaS Gateway

You can add TLS to your OpenFaaS Gateway URL with the following documentation: 1.0 SSL for the Gateway

  • Join OpenFaaS Insiders

OpenFaaS Insiders get regular email updates on project news and developments including videos, blogs, and early-access to the latest features. Join by becoming a sponsor on GitHub at any tier.

GitHub Sponsors

  • Need help?

Visit OpenFaaS Slack