loader

OpenFaas: Install Open Source FaaS Platform on Kubernetes Cluster

OpenFaas: Install Open Source FaaS Platform on Kubernetes Cluster

Introduction

In the rapidly evolving landscape of cloud computing, one of the more recent developments that has gained significant traction is the concept of Function as a Service (FaaS). In this article, we explore the idea behind FaaS, why it exists, and what we hope to achieve with its use. We then delve into OpenFaaS, an open-source solution offering a platform for deploying serverless functions, its origin, and how it compares with other solutions.

Understanding Function as a Service (FaaS)

Function as a Service, often referred to as FaaS, is a category of cloud computing services that provides a platform for developers to execute and manage application functionalities without the complexity of building and maintaining the infrastructure typically associated with developing and launching an app. It’s a type of serverless computing where applications are broken down into smaller, interchangeable parts, known as functions.

The existence of FaaS can be attributed to the need for efficiency, scalability, and flexibility in software development and deployment. As businesses scale, the need for efficient resource use becomes paramount. FaaS allows developers to run pieces of code (functions) in response to specific events, paying only for the computing time consumed. This model promotes microservice architecture and event-driven programming, reducing the need for redundant code and enhancing scalability.

Source: https://kinsta.com/

The Potential of Function as a Service

FaaS brings several benefits to the table, impacting the way software is developed and delivered. One of the key features is its scalability. It can automatically scale up or down based on demand, ensuring optimal resource utilization.

In addition, FaaS fosters a faster development cycle. By eliminating the need to manage servers, developers can focus on writing code, accelerating the time to market. Plus, FaaS's pay-as-you-go model reduces costs as you pay only for the compute time your functions use.

Furthermore, FaaS enables developers to create modular applications. This modularity enhances maintainability and makes it easier to update or modify individual components without affecting the entire application.

Introducing OpenFaaS

OpenFaaS is an open-source platform that makes it easy for developers to deploy event-driven functions and microservices to Kubernetes without repetitive, boiler-plate coding. OpenFaaS abstracts away the complexities of the underlying infrastructure, allowing developers to focus on writing effective code.

The Genesis of OpenFaaS

OpenFaaS was created by Alex Ellis in 2016 as a solution to the challenges he encountered while deploying and scaling applications in a cloud-native environment. Ellis envisaged a platform that was developer-centric, portable, and community-oriented, and thus, OpenFaaS was born.

OpenFaaS was built to leverage the power of existing container technology without exposing developers to its complexity. It offers an easy-to-use UI, a rich ecosystem of language templates, and integrations with popular tools, making it highly flexible and adaptable. Since its creation, OpenFaaS has received considerable recognition and support from the developer community.

Comparing OpenFaaS

OpenFaaS stacks up well against both proprietary and open-source FaaS solutions. Compared to proprietary solutions like AWS Lambda, Google Cloud Functions, and Azure Functions, OpenFaaS offers significant advantages, primarily revolving around portability and openness.

Unlike proprietary solutions that often impose vendor lock-in, OpenFaaS runs on any environment that supports containers, including popular container orchestration platforms like Kubernetes and Docker Swarm. This ensures you're not tied to a single cloud provider.

When compared with other open-source serverless frameworks such as Kubeless, Fission, and Knative, OpenFaaS's strengths lie in its simplicity, community support, and the breadth of its features. While all these platforms provide FaaS capabilities on top of Kubernetes, OpenFaaS stands out with its focus on simplicity and developer experience. It offers a straightforward installation process, a user-friendly UI, and detailed documentation, making it accessible to developers with varying levels of expertise.

Moreover, OpenFaaS provides an auto-scaling feature, allowing deployed functions to automatically scale up or down based on demand. This feature isn't as seamless or intuitive in other open-source solutions.

Feature/Service OpenFaaS AWS Lambda Google Cloud Functions Azure Functions Kubeless Fission Knative
Runtime Environment Any AWS Google Cloud Azure Any Any Any
Open Source Yes No No No Yes Yes Yes
Language Support Multiple Multiple Multiple Multiple Multiple Multiple Multiple
Auto-scaling Yes Yes Yes Yes Partial Yes Yes
Event-driven Yes Yes Yes Yes Yes Yes Yes
UI Dashboard Yes No No No No No No
Kubernetes Native Yes No No No Yes Yes Yes
Community Support Strong Strong Strong Strong Moderate Moderate Strong

OpenFaaS in Action

To understand the real-world application of OpenFaaS, consider a scenario where a company wants to implement a real-time data processing system. Data is continuously generated through various sources and needs to be processed immediately.

Using OpenFaaS, the company could create different functions for each processing task - one function could clean and standardize the incoming data, another could aggregate the data, and yet another could analyze the data and extract insights.

Whenever new data comes in, these functions are triggered, process the data, and then go idle. This way, the company only uses computational resources when data is being processed, significantly reducing costs. Plus, if there's a sudden surge in data, OpenFaaS automatically scales the functions to handle the increased load, ensuring that the system can handle varying amounts of data without manual intervention.

Install OpenFaaS on Kubernetes

Prerequisites

For the operation of OpenFaaS, we will need to designate two distinct namespaces: openfaas, which will serve as the host for OpenFaaS resources, and openfaas-fn, which will act as the habitat for the pods operated by OpenFaaS.

~$ kubectl create namespace openfaas

~$ kubectl create namespace openfaas-fn

In addition, securing our OpenFaaS Gateway Ingress with a TLS Certificate is crucial. This can be acquired for free using Cert Manager and Let's Encrypt. For detailed steps on how to obtain and implement such a certificate, refer to the following guide:

How to get Free SSL Certificate for Kubernetes Cluster using Let’s Encrypt
Using SSL is essential for any website that wants to protect its users’ sensitive information. Without SSL, data can be intercepted and stolen by hackers, putting users’ privacy and security at risk.

Install OpenFaaS

The highly recommended method for deploying OpenFaaS on Kubernetes involves leveraging Helm Charts. OpenFaaS provides an official Helm Chart to streamline the installation process on a Kubernetes Cluster. To get started, we need to add OpenFaaS to our Helm repository with the following command:

~$ helm repo add openfaas https://openfaas.github.io/faas-netes/

~$ helm repo update

Create a file values.yml and use it as Helm Chart Values:

Install it:

~$ helm install openfaas openfaas/openfaas --namespace openfaas -f values.yaml

Lastly, we create Ingress Resource for OpenFaaS API Gateway

Install it:

~$ kubectl -n openfaas apply -f ingress.yaml

Verify installation

~$ kubectl -n openfaas get pods
NAME                    READY   STATUS    RESTARTS   AGE
alertmanager-xxx        1/1     Running   0          10m
basic-auth-plugin-xxx   1/1     Running   0          10m
gateway-xxx             2/2     Running   0          10m
nats-xxx                1/1     Running   0          10m
prometheus-xxx          1/1     Running   0          10m
queue-worker-xxx        1/1     Running   0          10m
redis-master-0          1/1     Running   0          10m

Boom! You have reliable and scalable FaaS Platform on your Kubernetes Cluster for free..


About 8grams

We are a small DevOps Consulting Firm that has a mission to empower businesses with modern DevOps practices and technologies, enabling them to achieve digital transformation, improve efficiency, and drive growth.

Ready to transform your IT Operations and Software Development processes? Let's join forces and create innovative solutions that drive your business forward.

Subscribe to our newsletter for cutting-edge DevOps practices, tips, and insights delivered straight to your inbox!