Hi Today I am going to introduce Quebic - FaaS Framework. Quebic provides way to write server-less functions to run on Kubernetes. It supports for Java, Python, NodeJS runtimes.

The key difference between Quebic and existing FaaS frameworks is, With Quebic you can develop highly available back-ends to serve real-time and also supports to execute on-demand tasks. Most of the existing FaaS frameworks are most suitable only for executing on-demand tasks.

Main Topics

Prerequisites High Level Overview of Quebic Setup Quebic API Gateway Functions

1. Prerequisites

Before start Qubic you need to setup Kubernetes cluster. There are several ways. Here you can find more details.

You can easily setup Minikube on your local machine that will gives single node Kubernetes cluster.

Or you can use hosted solution such as Google Kubernetes Engine, Azure Kubernetes Service, Amazon Elastic Container Service for Kubernetes, etc.

2. High Level Overview of Quebic

Quebic Manager

Main controller and responsible for deploying and managing functions and other components.

Function Container

The user provided source code is running inside function container. The Function container are deploying by quebic-manager into kubernetes.

Event Bus

Delivering events from publishers to consumers. Powered by RabbitMQ.

API Gateway

Transforming HTTP payloads into event payloads.

Nginx Ingress

Front door for outside clients. Used as a proxy for API.

Quebic CLI

Command-line Interface (CLI) is a tool to that provides a interface to communicate with quebic-manager.

3. Setup Quebic

Download binaries

Download binaries from here. Save and extract it into preferred location.

Run quebic manager

Jump into Quebic binaries location. Then run this command

quebic manager start

This command deploy and start the quebic-manager inside Kubernetes cluster. It takes time to setup Ingress. If you are using in MiniKube cluster it will take few seconds. But for Hosted cluster like GKE, it will take few minutes.

Connect cli with manager

This command will config quebic-cli to connect with quebic-manager.

quebic manager connect

All the configurations related to quebic-cli are located in $HOME/.quebic-faas/cli-config.yml file. Above command will change the quebic-manager connection string.

Check status of quebic-manager

To check status of the manager run this command.

quebic manager status

Fetch quebic-manager logs

You can fetch quebic-manager’s logs by running this command.

quebic manager logs

4. API Gateway

As I mentioned all incoming traffic coming to the API Gateway through the nginx-ingress. To get ingress details run this command.

quebic ingress describe

It will display IP address of the Ingress. You can reach out API Gateway by setting Host headers as api.quebic.io Sample curl command.

curl http://<ingress-ip>/<resource-path> -h "Host: api.quebic.io"

5. Functions

For this demo i will create two functions. One is user-validate function and other one is user-create function.

user-validate function

Inside this function, it receives a user object as an input then it get email attribute from user object. Finally it checks the email is valid one or not then response back. This is the source code for it.

Before create the function you have to provide specification of your function. According to that spec quebic-manager deploys it into Kubernetes. This is the spec file of user-validation function.

Under function section, you can define function’s run-time configurations.

line 2 : Name of the function

line 3 : Source location of the function. Supports for single source file or packaged tar.gz file when NodeJS run-time.

line 4 : Exported handler of the function.

<handler file>.<exported handler>

line 5 : Run-time of the function

line 6 : Number of replicas you needs to keep for the function

line 7–8 : Event list. Function can listen to mulitiple events.

line 9–11 : Environment variables

Under route section, you can define how to config HTTP routing to access the function through the API Gateway.

line 14 : HTTP method

line 15 : Resource path to access function

line 16–18 : Mapping between HTTP request parameters and event payload attributes

line 19–20 : HTTP headers needs to pass into function

Lets create this function. Set file path of function spec file to --file parameter. Run this command.

quebic function create --file <user-validate-function-spec>.yml

After create the function you can test it using Quebic CLI. Run this command.

quebic function test --name <function name> --payload '{"message":"hello"}'

This is how to execute function through the API Gateway. Sample curl command.

user-create function

This function receive user object. Then it publish UserValidate event which listening by user-validate function. Then user-create function waits until response receive from user-validate function.

If responses is success one, then it create a new user and return id of created user. Otherwise return error response. This is the spec file of user-validation function.

This is the source code for it.

This is the spec file of user-create function.

I have already covered most of the stuffs in previous section.

line 3 : Source location of the function. Supports for jar file when Java run-time.

line 4 : Class path of the handler.

line 8–12 : As I mention earlier Quebic is most suitable for highly available back-ends also supports to execute on-demand tasks.

With Quebic you can config wake up method of the function-container according to your requirements. That means developers can config function to start its container by requests and also can config ideal-timeout of the container. Or developer can config function to run its containers continuously.

Here I configured this function to spin-up by a request.

line 17 : Async invocation. With that configuration API Gateway is not going to wait until task complete. It immediately response back request-id to API caller. Then API caller can check the response for its request using that request-id. Eventually caller get response for his request.

Create the function using this command.

quebic function create --file <user-create-function-spec>.yml

This is how to execute function through the API Gateway. Sample curl command.

It response request-id to get response of the request. This is a curl command to get response by passing request-id.

I have covered most of the key functionalities of the Quebic. You can find related source code for this in here. If you want to know how Quebic can be used for Microservices based development refer this article Event-driven Microservices with Quebic. I really expecting your feedbacks. If you have any concerns leave a comment below. Thank you.