Running serverless functions on premises using OpenFaas with Kubernetes

Earlier most of companies had monolithic architecture for their cloud applications (all the things in a single package). Nowadays companies are decomposing their monolithic app’s business functions in to several micro-services (Isolated component that has single responsibility). Thus thereafter serverless concept came with kind of different concept.

Serverless!! really running without a server ?

Nothing can be executed without servers. We need resources to do calculations 😎. Whereas the word “serverless” highlights these key principles

  1. Less maintenance
  2. Inexpensive

Serverless on premises?

Running a serverless function is very easy. We can simply use AWS Lambda or GCP function or whatever from cloud providers. So how about if we do have some servers of our own. If you are running Kubernetes orchestration engine on servers, it’s very easy using OpenFaas.

OpenFass — OpenFaaS — Serverless Functions Made Simple for Docker & Kubernetes

Open Faas (Function as a service) is a framework for creating serverless functions on Kubernetes or Docker. It’s an open source project released under MIT License and written in Go.

Setting up OpenFaas on Kubernetes

According to my researches Rancher is the best tool to build a kubernetes cluster on premises(on bare metal servers or on virtual machines). Whole process can be done simply by hitting few kubectl commands with your keyboard 🧐.

git clone https://github.com/openfaas/faas-netes
cd faas-netes
kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml
kubectl apply -f ./yaml

OpenFass Architecture

Deploying a function

You can deploy any working binary as a function (Since it will deal with stdin and stdout). As an example let’s see about c#

cd csharp
docker build -t <docker-hub-username>/test-csharp .
docker login
docker push <docker-hub-username>/test-csharp

Motivation for open source projects

Watch the story of Alex Ellis(founder of openfaas) and see how community gather around open source projects.

Programmer | Author of Neutralinojs | Technical Writer

Programmer | Author of Neutralinojs | Technical Writer